Mittwoch, 20. April 2011

Message creation in orchestrations “from scratch”

In some cases it is useful to create a BizTalk message without mapping it from another message.


If you have a Message Assign shape and you access a distinguished field on the message like


msgSample.ErrorCode = “4711”;


without a Transform shape in advance you get the following error during compiling


Message part has not been initialized in construct statement


This is because the xml message has not been initialized. For some reason it is necessary that the “empty” message needs to already contain a tag for the field ErrorCode.


To avoid this issue, you would add a Transform shape with a map, where the root node of the source schema is linked with the field ErrorCode on the target schema. Without mapping you need to construct this manually. For me, the following worked well:


I added a variable with name tempXml of type System.Xml.XmlDocument to the orchestration. In an expression shape I loaded an XML template and constructed the message.


tempXml = new System.Xml.XmlDocument();
tempXml.LoadXml(“…”);

construct msgSample
{
msgSample = tempXml;
msgSample.ErrorCode = “4711”;
}


The XML template for LoadXml can be generated on the schema file in Solution Explorer.


Another way could be to call custom code like


construct msgSample
{
msgSample = CustomClass.CustomMethod(...);
msgSample.ErrorCode = “4711”;
}


The method should be declared in a separate c# project as follows


public class CustomClass
{
public static XmlDocument CustomMethod(...)
{
...
}

}

BizTalk Server 2010 Feature Pack

Slightly after the release of BizTalk Server 2010 a Feature Pack has been released. This feature pack contains only one feature which is named BizTalk Server 2010 AppFabric Connect for Services. It provides for bridging the capabilities of BizTalk Server and Windows Azure AppFabric thereby enabling enterprises to extend the reach of their on-premise Line of Business (LOB) systems and BizTalk applications to cloud.


Download