Friday, July 06, 2012 4:09 PM Mikael Sand

Setting custom SOAP headers in the WCF adapter

While browsing for the answer to the question: “How do I add SOAP-headers to a message sent using the WCF-custom or WCF-basicHttp adapter?” I never really found a good, short answer. So I thought I’d give it a go.

Setting SOAP headers

I assume you know what SOAP-headers are and why you might use them. If not, then back to basics.

In my case the client needed BizTalk to send request with the WS-addressing SOAP header called “To”. I needed to know the easiest way to do this and preferably using configuration and no orchestrations.

To the best of my knowledge, this is the simplest way to do it.

Using a pipeline

Use a pipeline component to promote this property: http://schemas.microsoft.com/BizTalk/2006/01/Adapters/WCF-properties#OutboundCustomHeaders.

My guess is that you local BizTalk-code hub already have a pipeline component to promote arbitrary values. If you do not, the code for promoting the property is here.

The only thing to remember is that the value of the property is a bit special. You can hard code the values of your headers, even using xml-formatting; no problem, but you have to surround the value with a <headers> tag.

<headers>
<h:To xmlns:h="http://www.w3.org/2005/08/addressing">rcvAddr</h:To>
</headers>

This will result in the WCF adapter serializing a SOAP envelope with SOAP headers that contains the value you give between the <headers> tag.

Here is the result in my environment:

image

Using an orchestration

This is a bit more work, but a very useful way to get the same result of you already have an orchestration. A bit more information can be found here.

What you basically do is setting the property from an assignment shape, much like you would access a FILE.RecieveFileName.

outboundMessageInstance(WCF.OutboundCustomHeaders) =
"<headers><add:To xmlns:add="http://www.w3.org/2005/08/addressing">rcvAddr</h:To></headers>"

Filed under: ,

Comments

No Comments