Today, I go through a solution to send XLangMessage to .net assembly from an Orchestration and update it. After update I need it in my Orchestration. For this I have created a project which I think it can help others.
I have created an Orchestration project named “CallNetAssemblyBySendingXLangMessageAndUpdate”. I have added the following simple schema in this project named “Book.xsd”.
Then I have created added an orchestration named “CallAssemblyXLangMessage.odx” in project. In this orchestration I am receiving the Book.xsd type message in receive shape. After this I have added the message assignment shape in the transform shape to update the values of message received of Book.xsd type. In this Construct shape I am creating a new message of Book.xsd type. In this message assignment shape I am calling the .net assembly in which I am updating the message.
I am sending the message in .Net assembly method as XLANGMessage parameter. Before going further I want to explain how I am accepting the message and updating it and return it.
For this I have added a new Class Library Project named “UpdateXLangMessage” in the Solution.
You need to create the Book class of Book.xsd created in Orchestration project by using XSD.exe util. You can create this class by using the following command at Visual Studio Command Prompt:
xsd.exe /c Book.xsd
This will create a Book.cs class. Add this project in class library project UpdateXLangMessage.
Now to receive XLangMessage and update it I have added the following class in this project.
========================================================
using System;
using Microsoft.XLANGs.BaseTypes;
namespace UpdateXLangMessage
{
public class UpdateMessage
{
public static Book UpdateBookMessage(XLANGMessage xlngMsg)
{
//Serialize message into Book Object
Book objBook = (Book)xlngMsg[0].RetrieveAs(typeof(Book));
try
{
//Update Book Object
objBook.Author = "Vijay Modi"
objBook.BookID = "00001"
objBook.BookName = "Biztalk 2006 R2"
objBook.Price = "Free"
objBook.Publisher = "Testing Publisher"
}
catch (XLANGsException xlngEx)
{
throw xlngEx;
}
catch (Exception ex)
{
throw ex;
}
//return book object
return objBook;
}
}
}
=========================================================
Build this class. Assign a Strong Name key to this project and add it in GAC using following command in Visual Studio Command Prompt.
gacutil /i UpdateXLangMessage.dll
Now we are going back to our Orchestration project. In Orchestration project add the reference of the .Net class library project.
Now in our Orchestration’s message assignment shape write the following expression:
//msgBookNew is the new message created of Book.xsd schema type
//msgBook is the message received in receive shape
msgBookNew = UpdateXLangMessage.UpdateMessage.UpdateBookMessage(msgBook);
Add the send shape just below the Transform shape in the orchestration. Assign the msgBookNew message in this send shape. The orchestration will look like as below:
Now deploy your orchestration project and test it. Some important reference I have found on the net are as below:
Reference:
http://support.microsoft.com/kb/917841
http://msdn.microsoft.com/en-us/library/aa995576.aspx
You can write your comments here:)
Regards,
Vijay Modi