Monday, 9 February 2009

Add Additional SOAP Header while Publish Orchestration as Webservice

Last couple of days I was busy with documnetation work in my office and one of my friend request me to provide an example for how to add an additional Soap Header while publishing the orchestration as webservice. I just tried to provide a URL from google search, unfortunately I could not find any right answer. Then I started my new journey to prepare my own example.

I was trying to publish my Orchestration as Webservice and tried to add additional SOAP header ( provided option while publish). I created a new Property Schema and changed the Target Namespace as

But when I try to select the Schema while publishing in the Tool , I couldn’t find the schema from the list. I was surprised and recollected myself what I was doing wrong?. And as per my observations I found that Document schemas are in the list to add as Additional soap Header but not Property schemas.

But how this document schema can be treaded as SOAP Header ?? any guess ..?
Lets do a deep drive to and see how we can add additional soap header for your Published Webservice.

First step is to create normal Document Schema and Change Root Node as “AuthenticateSoapHeader”. And add two Field elements under root node like UserName , Password.
Create a Property Schema and Rename the Property1 element as “AuthenticateSoapHeader” and set the property Schema Base = “MessageContextPropertyBase” also the Target NameSpace as

For more details of creating SOAP Header Schema , refer the below link (Steps to Create Soap Header Schema)

Lets try to understand the purpose of creating Property Schema : When ever you add Document schema as Additional SOAP header at publish tool BizTalk Creates an Soap header class with the root node of your Document Schema. In my Example AuthenticateSoapHeader is the Root node of my Document Schema.

If you look at the MessageContext Property of your Orchestration Instance for Incoming Message , It shows clearly that AuthenticateSoapHeader is one of the value sent along with incoming message as part of Soap header.

Now next step is to get the SoapHeader XML data and assign the value to Document Schema.
Write the below code at MessageAssignment Shape

// get SoapHeader Information from Context
vData= IncomingInvoiceMsg(SoapHeaderExposeOrch.AuthenticateSoapHeader);
//Load SoapHeader xml data and assing to Document Schema
vXmlObj= new System.Xml.XmlDocument();

//Assign SoapHeadr XML to Document Schema

reach me if you have any issues :

1 comment:

  1. Thanks Raj.
    Your article helps me a lot. I was sticking on this issue from past 3 days..finally with the help of your article and your quick response via your email I sorted it out.

    Good article