I have a bot made in C # connected to a Web Service. To make a request successfully I have to add several headers, can someone tell me how to do it?
I have a bot made in C # connected to a Web Service. To make a request successfully I have to add several headers, can someone tell me how to do it?
To assign the header to the service, first it must be defined
Web Service in ASP .Net (Security by SOAP Authentication): Part 5
let's use the basic article, analyze the "Step 6", you will see that the class that inherits from SoapHeader
public class UserDetails : System.Web.Services.Protocols.SoapHeader
{
public string userName { get; set; }
public string password { get; set; }
}
then define the attribute in the webmethod
[WebService]
public class MyServiceClass
{
public UserDetails User;
[WebMethod]
[SoapHeader("User", Required = true)]
public string SayHello(string userName)
{
//codigo
}
}
If you already had it you should surely update the web reference
, then when instantiating you can assign the data of the header