HowTo define a Custom Soap Header in BizTalk. Expose it, Consume it , even map them..

 

1. Create the schema that defines your custom header. This schema should be a NORMAL schema. (Give it a decent rootnode name)

2. Create a PROPERTY schema with TargetNamespace : http://schemas.microsoft.com/BizTalk/2003/SOAPHeader.

3. Make sure you define a property in the PROPERTYSCHEMA with EXACTLY the same name as the ROOTNODE of the schema in step 1

4. Make sure you set the set the "Property schema base" to "MessageContextPropertyBase" !!!!!

5. Deploy.

That's it...... I was really confused by other posts on the web that are just not clear enough... But the summary above is very short so I will explain a bit more.

First step.

Create a normal schema that represents your custom header. Below is a screenshot of my schema.

But I also wanted to send a custom header, so I had to create a second schema representing my outgoing envelope.

 

Second step.

Now I had to create a property schema. Taking care that my property names where EXACTLY the same as the Rootnodes in the schemas. I also had to set the namespace to the correct SOAPHeader namespace.

After setting  the "Property schema base" to "MessageContextPropertyBase” I deployed everything. And I was basically ready to go.

The orchestration

I created a very simple orchestration. It Receives a message, Maps it to the output and sends the output back. More on this orchestration later. I then generated a web service With the wizard that came with Biztalk. It is probably important to mention that when generating the service, I added extra SOAP headers. As the inbound header I specified the “inHeader” schema  and as the outbound header I specified the “outHeader” schema (So not the propertyschema). Then after some wizardry of the wizard, I fired up my trusted WebService Studio tool” and hit the GET button. I was presented with the following picture..

Everything I was expecting, was there. So it was very easy to send and receive headers.

Receiving

After receiving the message, the Adapter (it also works with PASSTHROUGH) will strip off the header and put it into the context property. Below is a screenshot of the received message. As you can see there is no messagetype set so it was received via a passthrough pipeline.

But how nice … the context property "inHeader" contains an XML document with the content of the SOAP header.

So if you want to get to a Specific SOAP Header in an Orchestration. The following code should do the trick.

 

Sending

For Sending messages with the header it works the other way around. Just make sure you have set the content of the outbound header context property to an XML document representing a valid header. I created mine with the mapper.

Then I threw in a shape where I put the contructed document into the context property…

And Presto….

 

 

 

 

Published Fri, Jun 13 2008 1:37 PM by Patrick Wellink
Filed under: ,

Comments

# SOAP Headers in BizTalk

Monday, March 09, 2009 6:59 PM by Marcel's SOA & BPM blog

I recently had to do a proof of concept, where I had to connect BizTalk Server to some internal web services

# re: HowTo define a Custom Soap Header in BizTalk. Expose it, Consume it , even map them..

Monday, May 24, 2010 7:34 AM by Pandit

Can you also publish how it could be done with WCF based services.

Regards,

Pandit.

# re: HowTo define a Custom Soap Header in BizTalk. Expose it, Consume it , even map them..

Monday, May 31, 2010 1:47 PM by alejo

Hi Patrice,

Thanks for this post. It's exactly what I want to do.

I am getting getting this error, though:

The namespace 'XXX' already contains a definition for 'inHeader'

That's apparently because the namespace of the message's inHeader is the same as the node inHeader in the property schema.

Am I missing something?

# re: HowTo define a Custom Soap Header in BizTalk. Expose it, Consume it , even map them..

Monday, May 31, 2010 4:26 PM by Patrick Wellink

No in WCF there are two context properties, inboundheaders and Outbound headers. (I Believe.. google and you will find them). Those context properties contain an instance of a XML document with all the headers. So it would be as simple as get that context, write to an xml document, and then import that as a schema. So then you can do the same trick ....

# re: HowTo define a Custom Soap Header in BizTalk. Expose it, Consume it , even map them..

Saturday, October 15, 2011 9:49 AM by Neel Sarvaiya

Thanks a lot... :)

Leave a Comment

(required) 
(required) 
(optional)
(required) 
Please add 7 and 2 and type the answer here: