Biztalk 2004 Integration Experiences

Friday, February 04, 2005

How to Get Length of a Message Field in an Orchestration?

The title question might sound a bit stupid, but one of the main limitations I have seen with the Xlang C# Pseudo syntax in Orchestration is it lacks certain simple programming abilities.

For example in C# if you want to find length of string you can easily do it as below

string strTest = "Test string";
int intTestLen = strTest.Length;


You cannot do the above in the Expression Editor or Message Assignment shape in an Orchestration, which is frankly a bit disappointing.

So if you have to find a length of a field in a message, the proper thing to do would be to send that message to a custom .Net Assembly and get the length back.

To me it sounds it's a lot of work for just finding the length of string, so I tried something else.

I used the xslt "string-length" function in xpath function (Which is very powerful and useful in Orchestration) to fetch the length of a field. for ex. if msg1 is your message and field1 is the field whose length you want to find, you can write the statement as below in a Expression editor to get the length

intTestLen = xpath(msg1,@"string-length(/Test/field1/@value)");

This is just a workaround and to me it's convenient than passing the message to a .Net component

0 Comments:

Post a Comment

<< Home