Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

How do I provide information to the Web Service when the information is required as a SOAP Header?

header service Soap web
0
Posted

How do I provide information to the Web Service when the information is required as a SOAP Header?

0

The key here is the Web Service proxy you created using wsdl.exe or through Visual Studio .NET’s Add Web Reference menu option. If you happen to download a WSDL file for a Web Service that requires a SOAP header, .NET will create a SoapHeader class in the proxy source file. Using the previous example: public class Service1 : System.Web.Services.Protocols.SoapHttpClientProtocol { public AuthToken AuthTokenValue; [System.Xml.Serialization.XmlRootAttribute(Namespace=”http://tempuri.org/”, IsNullable=false)] public class AuthToken : SoapHeader { public string Token; }} In this case, when you create an instance of the proxy in your main application file, you’ll also create an instance of the AuthToken class and assign the string: Service1 objSvc = new Service1(); processingobjSvc.AuthTokenValue = new AuthToken(); objSvc.AuthTokenValue.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123