Sometimes we need to pass a BizTalk message to an external assembly for applying complex business logic, extracting some information etc. We need to use Microsoft.XLANGs.BaseTypes namespace in defining the class. And create method or function with parameter type as XLANGMessage.
For more details about how to comsume external assembly in BizTalk orchestration.
Suppose a student schema is defined as a BizTalk message and used in orchestration. And this student message needs to be sent to an external assembly for some business logic.
using System;
using Microsoft.XLANGs.BaseTypes;
namespace StudentMessage
{
public class Message
{
public static XmlDocument UpdateStudentMessage(XLANGMessage message)
{
//Serialise message into xmldocument Object
XmlDocument xmlDocument = (XmlDocument)message[0].RetrieveAs(typeof(XmlDocument));
//apply Business logic
return xmlDocument ;
}
If you want other information or string to return you can, it’s not mandatory to return xml document itself
public static string UpdateStudentMessage(XLANGMessage message)
{
//Serialise message into xmldocument Object
XmlDocument xmlDocument = (XmlDocument)message[0].RetrieveAs(typeof(XmlDocument));
String strValue = “”;
//apply Business logic
return strValue ;
}