BizTalk: Message Assignment shape. Assign value from one Schema to another Schema.

We can assign one schema to another by many ways. But best way to assign values to one schema from another schema is to use the Message assignment Shape inside the Message Construct shape. Let’s take an example for it.

Example: Conversion of BillingAddress to ShippingAddress. For this I have two Schemas BillingAddress.xsd and ShippingAddress.xsd. All the elements of both schemas are promoted to Distinguished Fields, so that we can access them in message assignment shape. Both schemas are as follows:



Now I have created an orchestration, in which I am assigning the values of BillingAddress.xsd to ShippingAddress.xsd. For this I have created two messages msgBillingAddress and msgShippingAddress of BillingAddress.xsd and ShippingAddress.xsd types respectively. I have created a variable named varXmlDoc of System.Xml.XmlDocument type. My orchestration will look like the follows:

You can see in the image that there I have added a Receive Shape which will accept the msgBillingAddress and at the last you can see that I have added a Send Shape to send the ShippingAddress using msgShippingAddress. Between these two shapes(Receive & Send Shape), I have added a shape through which I am assigning values of BillingAddress to ShippingAddress message. And for this I have added a Construct shape and inside it I have added a Message Assignment Shape.

Now the purpose of this article is to share how to assign one message to another one. I have added the following code to assign BillingAddress to ShippingAddress message.

//Create a new object of XMLDocument. For this we will use the Variable created as XMLDocument.

varXmlDoc = new System.Xml.XmlDocument();

//We need to Load the variable with dummy XML.

//It can be same as generated instance.

//Note here we have to assign that instance that we need in target, not the //source schema.

varXmlDoc.LoadXml(@"<ns0:ShippingAddress xmlns:ns0=""http://SampleXPath.ShippingAddress"">

<Address1>Test Address1</Address1>

<Address2> Test Address2</Address2>

<City>Test City</City>

<State>Test State</State>

<Country>Test Country</Country>



//Assign XMLDocument varSmlDoc variable to ShippingAddress message.

msgShippingAddress = varXmlDoc;

//Assign data to each element

msgShippingAddress.Address1 = msgBillignAddress.Address1;

msgShippingAddress.Address2 = msgBillignAddress.Address2;

msgShippingAddress.City = msgBillignAddress.City;

msgShippingAddress.Country = msgBillignAddress.Country;

msgShippingAddress.State = msgBillignAddress.State;

msgShippingAddress.Zip = msgBillignAddress.Zip;

I think now you can understand how to assign one schema to another schema using Message Assignment shape in BizTalk Orchestration.

Let me know if you have any confusion in this article.


About Vijay Modi

Having 12+ years of experience in web application development. Expertise in various domains like E-Commerce, E-Learning, Insurance. I have expertise in web application development, window application development, Performance improvement, bug fixing etc. I have worked on various Microsoft technologies including ASP.Net, MVC, WebApi, WCF, Entity Framework, WPF, Window Application Development, AWS, Azure, AngularJS 2.0 / 1.5.2, .NetCore framework, jQuery. I am believing in quality work and achieving deadlines. Also like to work on new technologies and quick learner.
This entry was posted in BizTalk Server and tagged , . Bookmark the permalink.

4 Responses to BizTalk: Message Assignment shape. Assign value from one Schema to another Schema.

  1. IEHeU says:

    Please thank the Entire team,

  2. kalpana says:

    Hey there Vijay!
    I’m a beginner in BizTalk technology.In your “BizTalk: Message Assignment shape. Assign value from one Schema to another Schema.” blog,I couldn’t understand how to test the app.Means how to check whether the data from BillingAddress Schema has been copied to ShippingAddress Schema .Kindly help.

  3. Harish says:

    I have tried like the above lines of code, but i am getting below error: Could you please help me in this –

    The published message could not be routed because no subscribers were found. This error occurs if the subscribing orchestration or send port has not been enlisted, or if some of the message properties necessary for subscription evaluation have not been promoted. Please use the Biztalk Administration console to troubleshoot this failure.
    MessageId: {B0DD3EC7-CE8C-403D-9B98-3891DECD3227}
    InstanceID: {B159B837-7F7A-4ABC-A162-A11092B93A39}

  4. Harish says:

    Hi Vijay,

    I have done the same procedure again. but still getting this below error.could you help me in this please:

    This service instance exists to help debug routing failures for instance “{E0B66B2D-B5E0-4832-BFD3-66828CB72DC6}”. The context of the message associated with this instance contains all the promoted properties at the time of the routing failure.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s