1

I have generated a proxy class from a wsdl file (C# VS 2008) The webservice expects an element within the soap header. When I try to add this element using proxy.RequestSoapContext.Envelope.Header I receive a null error. The envelope is null. How do I am a custom element to the header ?

Many thanks.

1 Answer 1

1

Try this

EndpointAddressBuilder endpointAddressBuilder = new EndpointAddressBuilder(proxy.Endpoint.Address); foreach (var item in headers) //headers is a Dictionary<string, string> endpointAddressBuilder.Headers.Add( AddressHeader.CreateAddressHeader(item.Key, "nameSpace", item.Value)); proxy.Endpoint.Address = endpointAddressBuilder.ToEndpointAddress(); 

Hope this works for you.

Sign up to request clarification or add additional context in comments.

7 Comments

Thankyou Amar. That worked! It took me a while as my generated proxy was from wsdl.exe rather than svcutil.exe.
On the off chance I am now getting the error No SOAPAction Header defined. Any thoughts ? I'm new to web services and find it a mine field of objects etc.
Answered this myself. Switched from WcfBinding to Basic.
Great to hear that. You can check this post also, might help you.
Hi Amar. I hope its not inappropriate to ask a question like this. Its just you know the context and it might be easier to answer. I am using client.Endpoint.Contract.ProtectionLevel = System.Net.Security.ProtectionLevel.Sign This doesnt fully work as the URI of the signature points to _0 but the message body does not have an ID. I have been pulling my hair out looking for where to specify an ID. Any suggestions would be most welcome. (As an aside I find the MS way of implementing web services the most messy and awkward) Kind regards Tom
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.