3

We were given a set of ASMX services to consume. We have no say in how these services are implemented. We have generated a number of proxies with wsdl.exe tool but for some reason unknown to me, these generated proxies don't have any means for including custom SOAP headers.

Basically, I need a way to add custom header data to various service calls.

I am aware of existence of SoapExtension class but unfortunately we're not allowed to use that due to supposed performance issues.

Are there any alternative ways of customizing/adding header data in SOAP requests?

John Saunders
  • 160,644
  • 26
  • 247
  • 397
Vex
  • 1,179
  • 3
  • 15
  • 24

1 Answers1

5

you can use SoapHeader / SoapUnknownHeader to extend the generated proxy for this:

EDIT - as per comments:

To include a custom namespace see the sample code here.

Yahia
  • 69,653
  • 9
  • 115
  • 144
  • Awesome. Using SoapHeader attribute works for me. Do you have any idea how to ensure that elements in the soap header are assigned a proper custom namespace? Should I use [XmlType] attribute with Namespace property for that? – Vex Nov 15 '11 at 08:04
  • I needed to do the same found answer in here: http://stackoverflow.com/q/18886660/637142 – Tono Nam Sep 12 '15 at 20:28