Real-life experiences gained on cutting edge BizTalk projects from the City of London.

Wednesday, October 19, 2005

WWF and Cutting down BTS 2004 shapes

Have you ever wondered if there is a way to cut down the number of BizTalk shapes you need? Well there is, however this technique should only be used if you understand exactly what the effect is... Many BizTalk developers are aware of the ability to review the intermediate code that BizTalk generates in its 'code behind'. This code is used to compile your orchestration into CLR. To simply review this code all that is needed is to right click on the orchestration and open it in notepad, at the end of the orchestration XML designer code you will find the XLANG/S code. This language is largely undocumented and really should be C# but isn’t for some unknown reason (Answers on a postcard). After reviewing the code and the documentation its possible to construct your own shapes. For example to avoid using a constructing message you would write in an expression shape:

construct msgTest { msgTest = orchHelper.CreateMessage(); }


You can combine the above with more than one shape in an expression shape: i.e:


scope
{
message SomeSchema.NACK msgNACK;

body
{

construct msgNACK { msgNACK = orchHelper.CreateTestMessage();
}

exec SomeOrch.HandleNACK(msgNACK, MQOutLoc);

}
exceptions
{
catch (System.Exception ex1)
{
Debugger.WriteLine(ex1); }
}
}


The above expression contains a scope, construct and a start shape. I have used this method in some BTS projects to prevent rewriting NACK code every time. Unfortunately, in BTS 2004 it is not possible to have reusable shapes so the above code has to be a cut and paste job every time. This will be the same in BTS2006 but in windows workflow foundation you can create your own shapes and even use .NET in code behind, just like ASP.NET and Winforms read here for a primer ... http://msdn.microsoft.com/windowsvista/building/workflow/default.aspx?pull=/library/en-us/dnlong/html/WWFIntro.asp John