I am working on a soap webservice in c#. It look like this:
public class MyService : System.Web.Services.WebService
{
public MyService()
{
}
[WebMethod]
public string Hello()
{
return "hello";
}
}
and I added a service reference to this web service from another website, so I can access the Hello()
method from there using the code:
MyServiceSoapClient client = new MyServiceSoapClient();
client.Hello();
Now I need to pass the credentials to that web service. I have tried:
MyServiceSoapClient client = new MyServiceSoapClient();
client.ClientCredentials.UserName.UserName = "test";
client.ClientCredentials.UserName.Password = "pwd";
client.Hello();
But I could not manage to get these credentials in the webservice ( in the Hello()
method).
How can I get these values in the webservice?