看看我的这个webservice有什么问题啊,在实例化时出错!!

ldw701 2004-10-22 11:21:23
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Web;
using System.Web.Services;

namespace NoxMailService
{
/// <summary>
/// mailsend 的摘要说明。
/// </summary>
[WebService(Namespace="Hello",Description="在Web Services里发送邮件。")]
public class mailsend : System.Web.Services.WebService
{
private string From;
private string To;
private string Subject;
private string Body;
private string AttFile;
private string Cc;
private string Bcc;
private string MailServer;
private string UserType;
private string UserName;
private string Password;
protected string to
{
get
{
return To;
}
set
{
To = value;
}
}
protected string from
{
get
{
return From;
}
set
{
From = value;
}
}
protected string subject
{
get
{
return Subject;
}
set
{
Subject = value;
}
}
protected string body
{
get
{
return Body;
}
set
{
Body = value;
}
}

protected string attfile
{
get
{
return AttFile;
}
set
{
AttFile = value;
}
}

protected string cc
{
get
{
return Cc;
}
set
{
Cc = value;
}
}

protected string bcc
{
get
{
return Bcc;
}
set
{
Bcc = value;
}
}
protected string mailserver
{
get
{
return MailServer;
}
set
{
MailServer = value;
}
}
protected string usertype
{
get
{
return UserType;
}
set
{
UserType = value;
}
}
protected string username
{
get
{
return UserName;
}
set
{
UserName = value;
}
}
protected string password
{
get
{
return Password;
}
set
{
Password = value;
}
}
public mailsend()
{
//CODEGEN: 该调用是 ASP.NET Web 服务设计器所必需的
InitializeComponent();
}
public mailsend(string usertype,string from,string to,string subject,string body,string smtpserver,string username,string password)
{
this.usertype = usertype;
this.from = from;
this.to = to;
this.subject = subject;
this.body = body;
this.mailserver = smtpserver;
this.username = username;
this.password = password;
}
[WebMethod]
public string MailSend()
{
return this.password;
}

#region 组件设计器生成的代码

//Web 服务设计器所必需的
private IContainer components = null;

/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
}

/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if(disposing && components != null)
{
components.Dispose();
}
base.Dispose(disposing);
}

#endregion

// WEB 服务示例
// HelloWorld() 示例服务返回字符串 Hello World
// 若要生成,请取消注释下列行,然后保存并生成项目
// 若要测试此 Web 服务,请按 F5 键

// [WebMethod]
// public string HelloWorld()
// {
// return "Hello World";
// }
}
}
在另外一个页面中实例化时出错,出错信息如下 :

c:\inetpub\wwwroot\HOHO\WebForm1.aspx.cs(50): 重载“mailsend”方法未获取“8”参数

localhost.mailsend objs = new HOHO.localhost.mailsend("admin","1","1","1","1","1","1","1");//就是这句报错!!
...全文
146 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
greystar 2004-10-23
  • 打赏
  • 举报
回复
在方法里添加参数列表.
greystar 2004-10-22
  • 打赏
  • 举报
回复
不要使用构造函数
xiaobo 2004-10-22
  • 打赏
  • 举报
回复
可以这样:
先定义
class Mail
{
private string From;
private string To;
private string Subject;
....
}

[WebService(Namespace="Hello",Description="在Web Services里发送邮件。")]
public class mailsend : System.Web.Services.WebService
{
[WebMethod]
public string MailSend(Mail mail)
{
processMail(mail);
return mail.password;
}
}

class test
{
public static void main()
{
Mail mail = new Mail(...);
mailsend

}
}
ldw701 2004-10-22
  • 打赏
  • 举报
回复
事实上只有这一个是webservice提供的方法!
[WebMethod]
public string MailSend()
{
return this.password;
}
ldw701 2004-10-22
  • 打赏
  • 举报
回复
To:greystar(greystar) and net_lover(孟子E章)
webservice中不能重载构造函数吗???哪我该如何给类中的属性赋值呢???

softchao 2004-10-22
  • 打赏
  • 举报
回复
NoxMailService.mailsend objs = new NoxMailService.mailsend();
objs.mailsend("admin","1","1","1","1","1","1","1");
孟子E章 2004-10-22
  • 打赏
  • 举报
回复
localhost.mailsend objs = new HOHO.localhost.mailsend();
objs.mailsend("admin","1","1","1","1","1","1","1");

62,074

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧