Web Service 中有如方法
[WebMethod(Description="名片用户 输入用户名,密码登录系统",EnableSession=true)]
public bool ValidateUser(string userName,string password)
{
if(userName=="admin"&&password=="admin")
return true;
return false;
}代理类中使用如下方法可以成功调用: [System.Web.Services.Protocols.SoapDocumentMethodAttribute(RequestNamespace = "http://callcard.zdit.cn/")]
public bool ValidateUser(string userName, string password)
{
object[] objs = new object[] { userName, password };
object[] results = this.Invoke("ValidateUser",objs);
return (bool)(results[0]);
}
但使用 把以上方法中的参数名改为基它名字, 就不能成功执行.
[System.Web.Services.Protocols.SoapDocumentMethodAttribute(RequestNamespace = "http://callcard.zdit.cn/")]
public bool ValidateUser(string name, string pwd)
{
object[] objs = new object[] { name, pwd};
object[] results = this.Invoke("ValidateUser",objs);
return (bool)(results[0]);
}
[WebMethod(Description="名片用户 输入用户名,密码登录系统",EnableSession=true)]
public bool ValidateUser(string userName,string password)
{
if(userName=="admin"&&password=="admin")
return true;
return false;
}代理类中使用如下方法可以成功调用: [System.Web.Services.Protocols.SoapDocumentMethodAttribute(RequestNamespace = "http://callcard.zdit.cn/")]
public bool ValidateUser(string userName, string password)
{
object[] objs = new object[] { userName, password };
object[] results = this.Invoke("ValidateUser",objs);
return (bool)(results[0]);
}
但使用 把以上方法中的参数名改为基它名字, 就不能成功执行.
[System.Web.Services.Protocols.SoapDocumentMethodAttribute(RequestNamespace = "http://callcard.zdit.cn/")]
public bool ValidateUser(string name, string pwd)
{
object[] objs = new object[] { name, pwd};
object[] results = this.Invoke("ValidateUser",objs);
return (bool)(results[0]);
}
可以执行到Web Service 定义的方法中去.
但参数就没有传过去了.如.调用第二个ValidateUser:
ValidateUser("name","pwd");
到了Web Service中就成了执行ValidateUser(null,null)
因为你传过去的是NAME,
userName节点值为null
[........]
Login(string userName,string password )
{
.....
}
该如何写..
应该如何写
[System.Web.Services.Protocols.SoapDocumentMethodAttribute(
Action = "http://callcard.zdit.cn/ValidateUser",
RequestNamespace = "http://callcard.zdit.cn/",
RequestElementName = "ValidateUser",
ResponseElementName = "Login"
)]
public bool Login(string userName, string password)
{
object[] results = this.Invoke("Login", new object[] { userName, password });
return (bool)(results[0]);
}
这种方法来调用...
但执行后的结果又无法返回来..