Wednesday, August 02, 2006

Web Services - parameter value missing

When you pass parameters to WebMethod, not only the function name has to be the same, but also the parameters have to match. For example:

Web Service



public class User : System.Web.Services.WebService
{
public User() {}

[WebMethod]
public bool Login(string pLogin, string pPassword)
{
// implementation here
return true;
}
}



Proxy



public class UserPX : Microsoft.Web.Services3.WebServicesClientProtocol
{
public UserPX()
{
this.Url = @"http://localhost/user.asmx";
}

public bool Login(string pLogin, string pPassword)
{
object[] res = this.Invoke("Login", new object[] {pLogin, pPassword});
return (bool)res[0];
}


}

No comments: