Friday, March 7, 2008

Base64Binary, XLANG, arrays, and you

The XML type xs:base64Binary maps to a byte array in the .NET framework. This is simple enough to manage in most any .NET application you can think of, but in BizTalk orchestrations, it can be a little more complicated.

The short story is this: BizTalk orchestrations are based on XLANG technology, which cannot comprehend arrays. This is why you can't create an orchestration variable of an array type. If you promote an xs:base64Binary field and try to use it anywhere in an orchestration, the framework will try to deal with it as a byte array and the orchestration will fail, even if you simply use an expression shape to hand it to a .NET method that is expecting a byte array as a parameter.

The solution is to access the field with an xpath that's wrapped in the "string()" xpath function, and manipulate it as a string variable. Maybe this means that you'll hand it to a .NET method and turn it back into a byte array. You can do whatever you want with it, except treat it as a byte array within an orchestration.

No comments: