If you are using the BizTalk Adapter for Host Applications (BAHA) included with BizTalk Adapters for Host Systems (BAHS), you might encounter an error similar to the following error if the BAHA (i.e. Transaction Integrator) application includes discriminated unions:
Log Name: Application
Source: BizTalk Server 2009
Date: Date Time
Event ID: 5743
Computer: Computer Name
The adapter failed to transmit message going to send port "port name" with URL "TI/<Any host type>/<Default RE>". It will be retransmitted after the retry interval specified for this Send Port. Details:"Non-Transactional Call ProgID = ‘ProgID', Method = 'Method Name' failed, error: 'Error serializing/deserializing XML document'".
In one reported case of this problem, an XSD file was created in Visual Studio. The input XML file created as part of the project was dropped in the input folder for the associated BizTalk Port. The XML file was picked up by the BizTalk Port, but an error like the one above was returned.
The problem is related to how discriminated unions are processed at runtime. The discrimated union is represented by a generic type as its type can only be decided at runtime. The schema that BAHA (Transaction Integrator) generates has an attribute “IsUnion” to indicate a XML element is a union. The TI runtime will extract the type info and format it to the one expected by the XML Serializer/Deserializer:
Basically, if the input XML document contains the following:
<ns0:Simplestring SimpleType="string" />
This will be translated to the following at runtime so XML can deserialize it to a union object:
<ns0:UNION1 d4p1:type="xs:string" xmlns:d4p1="http://www.w3.org/2001/XMLSchema-instance" />
Since the resulting translation refers to the “xs” namespace, this namespace has to be defined in the XML document.
The solution to the problem is to add the following to the root element of the input XML document to define the '”xs” namespace:
If the original XML document included the following in its root element:
<ns0:Test__Interface1__Method1__Request TIAssemblyVersion="1.0" xmlns:ns0="http://microsoft.com/HostApplications/TI/WIP">
The root element in the modified XML document would be as follows:
Once this change is made the “'Error serializing/deserializing XML document'” error should no longer occur.