Headers in request to WebService

0

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?

    
asked by Yamila Sosa 24.10.2018 в 19:52
source

1 answer

0

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

is defined
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

    
answered by 24.10.2018 в 20:36