O'Reilly logo

Microsoft Windows Communication Foundation 4.0 Cookbook for Developing SOA Applications by Steven Cheng

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding a dynamic SoapHeader into a message

When designing a WCF ServiceContract, we can add custom SoapHeaders into the WCF service operation through the ServiceContract member statically. In addition to this, we can also programmatically create a custom SoapHeader and add it into a WCF request dynamically.

How to do it...

  1. Create a custom SoapHeader instance.

    The first thing to do here is to generate an instance of the SoapHeader we want to add into the request message. WCF provides a built-in generic type called MessageHeader<T> for creating custom SoapHeaders containing different kinds of inner data properties. The following code snippet shows how we can generate a custom SoapHeader that contains some string data through the MessageHeader<T> type: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required