سؤال

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.

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top