Deserialization Issues

27 07 2008

There have been a few scenarios where the complexity of using a standard BizTalk map, have far outweighed using some custom code. This approach, prescribed in Professional BizTalk Server 2006 as the “Manual Mapping” technique, involves code generating types (xsd.exe) from the message schema and using some simple BizTalk object model to stream-in the message, craft a response and return it back to the BizTalk runtime. Snippet:

public Invoice Transform(XLANGMessage xlangMsg)
{
  Order order = (Order)xlangMsg[0].RetrieveAs(typeof(Order));
  ..
  return invoice;
}

While this approach has a number of pros and cons, it can definitely be a useful tactic given the situation. I am interested in how this “custom code” method differs from XSLT taking a performance perspective. My main concern, is the duplication of message definitions in multiple places, breaking the fundamental DRY (Don’t Repeat Yourself) principle.

In a real-world solution, code (similar to the above snippet) was bubbling up an System.FormatException: “The string ” is not a valid AllXsd value”. The consumer was on .NET 2.0, and (I assume) wsdl.exe (or Add Web Reference from VS.NET) had been used to create the proxy code for our web service exposed orchestration. Value type members (as opposed to reference type) of the message, generate two fields (and properties) in the resultant proxy code. One is for the value itself (e.g. a DateTime) and the other is a flag to indicate whether its value has been specified.

After some digging around, discovered that the consuming code had hard-coded a boolean “specified” flag value to true for a particular DateTime value. In other words it didnt matter if the actual value was specified or not, the flag always returned a true value. When it came to deserialization time on the server (in this case the custom map code) an empty (not null) value could not be assigned to the DateTime property of the object.

Advertisements

Actions

Information

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: