I am trying to connect to a soap service(wsdl) from the console in C#. My code is fairly simple, I added the wsdl to the project as a service reference, and the proxy class(?) was created as expected.
The service use a authentication key per message, and i cannot find anywhere to add it to the soap header. As a reference, this is the code i run inside my main method:
Api.Servicereference1.PortClient object = new Api.Servicereference1.PortClient();
object.testmethod();
The output from this piece is the following:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<testmethod xmlns="http://wsdlserver.com/soap"/>
</s:Body>
</s:Envelope>
However, what i want to achive is the following message sent, with the authentication:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<s:auth>key</s:auth>
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<testmethod xmlns="http://wsdlserver.com/soap"/>
</s:Body>
</s:Envelope>
Can anyone help me in the right direction, as to how I can add this custom header to my messages? Thanks.