I’m simply attempting to use a soap header for authentication purposes.
After adding a service reference to a client console application, the header shows as the first parameter in list instead of as a member on the client object.
Anyone have any idea what I’m doing wrong?
WebService:
public class Service1 : System.Web.Services.WebService
{
public CustomSoapHeader MyHeader;
[WebMethod]
[SoapHeader("MyHeader")]
public string HelloWorld()
{
return "Hello World";
}
public class CustomSoapHeader : SoapHeader
{
public string SomeProperty { get; set; }
}
}
Client:
class Program
{
static void Main(string[] args)
{
Service1SoapClient client = new Service1SoapClient();
client.HelloWorld(new CustomSoapHeader());
}
}
If by “Service Reference” you mean a WCF client, then the problem is that the server isn’t a WCF server. If you add the reference as a “Web Reference” then the header should appear as a member of the client proxy class.