MyWebService.asmx:
public class MyWebService : System.Web.Services.WebService
{
public AuthHeader Authentication;
[SoapHeader("Authentication", Required = true)]
[WebMethod]
public string HelloWorld(string strSex)
{
if (Authentication!=null && Authentication.Username == "suresh" &&
Authentication.Password == "kumar")
{
return "success";
}
else
{
return "failure";
}
}
}
public class AuthHeader : SoapHeader
{
public string Username;
public string Password;
}
Client:
protected void Page_Load(object sender, EventArgs e)
{
MyWebService obj = new MyWebService();//clinet
AuthHeader authentication = new AuthHeader();//header
authentication.Username = "suresh";
authentication.Password = "kumar";
obj.Authentication = authentication;
Response.Write(obj.HelloWorld("male"));
}
Labels: webservice
Subscribe to:
Posts (Atom)