Microsoft KB Archive/823435

= Problems may occur when you try to integrate an InfoPath 2003 Form with BizTalk 2002 =

Article ID: 823435

Article Last Modified on 7/28/2006

-

APPLIES TO


 * Microsoft Office InfoPath 2003
 * Microsoft BizTalk Server 2002 Standard Edition
 * Microsoft BizTalk Server 2002 Service Pack 1

-



SYMPTOMS
When you try to use Microsoft Office InfoPath 2003 to submit XML data to a Microsoft BizTalk 2002 Server application, the following problems may occur:  When you create an InfoPath 2003 Form template that integrates with BizTalk Server 2002, and you export an XSD schema from BizTalk, InfoPath 2003 may not correctly recognize all the data fields in the XSD schema. If BizTalk Receive parses the XML data that InfoPath 2003 submitted before that XML data is passed to the BizTalk Orchestration Engine component, you may receive the following error message:

Validate failed because the root element had no associated DTD/schema.

This error message may occur if the Pass Thru option is turned off in the Receive function. After BizTalk processes the XML data that InfoPath 2003 submitted, you cannot correctly open the XML data in InfoPath 2003. Instead, you may receive an error message that is similar to the following error message:

InfoPath cannot open the following file.

The file does not appear to be an InfoPath form.





CAUSE
These problems occur because of the way that BizTalk 2002 handles XML data when BizTalk 2002 validates the XML data. The structure of the XML data in BizTalk 2002 can be described either by the XML-Data Reduced schema (XDR) format or by the Document Type Definition (DTD) schema format. Both the XDR format and the DTD format have been replaced by the industry-standard XML Structure Definition (XSD) format. InfoPath 2003 uses the XSD format. Because there are differences in how the DTD schema format, the XDR schema format, and the XSD schema format describe the structure of the XML data, the InfoPath 2003 XML data is incompatible with BizTalk 2002 if the XML data is not modified. Additionally, InfoPath 2003 uses XML processing instructions that are not supported by BizTalk 2002.



RESOLUTION
To resolve the problems that may occur between InfoPath 2003 and BizTalk 2002, use the following procedures.

Force InfoPath 2003 to correctly recognize XML data fields in an XSD schema that is exported from BizTalk 2002
 Open the exported XSD schema in a text editor, such as Notepad.

Notice that BizTalk 2002 incorrectly marks groups of elements with an  element instead of with an  element. Edit the schema to correct this problem. To do this, follow these steps: <ol style="list-style-type: lower-alpha;">  Locate the following code: <xsd:element name=&quot;Order&quot;> <xsd:complexType> <xsd:choice minOccurs=&quot;1&quot; maxOccurs=&quot;1&quot;> <xsd:element name=&quot;OrderID&quot; type=&quot;xsd:integer&quot;/> <xsd:element name=&quot;OrderDate&quot; type=&quot;xsd:date&quot;/> <xsd:element name=&quot;ShipDate&quot; type=&quot;xsd:date&quot;/> </xsd:choice> </xsd:complexType> </xsd:element> </li>  Replace the previous code with the following code: <xsd:element name=&quot;Order&quot;> <xsd:complexType> <xsd:sequence minOccurs=&quot;1&quot; maxOccurs=&quot;1&quot;> <xsd:element name=&quot;OrderID&quot; type=&quot;xsd:integer&quot;/> <xsd:element name=&quot;OrderDate&quot; type=&quot;xsd:date&quot;/> <xsd:element name=&quot;ShipDate&quot; type=&quot;xsd:date&quot;/> </xsd:sequence> </xsd:complexType> </xsd:element> </li></ol> </li></ol>

Resolve the validation error that occurs when you submit the InfoPath 2003 Form to a BizTalk Receive function
To remove the XML processing instructions, the namespace declarations, and the xml:lang attribute from the XML data, follow these steps: <ol> Open a text editor, such as Notepad.</li> Create a new file. Name the file RemoveNamespaces.xsl.</li>  Make sure that the RemoveNamespaces.xsl file contains the following code: <xsl:stylesheet xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; version=&quot;1.0&quot;> <xsl:template match=&quot;@xmlns:*&quot;/> <xsl:template match=&quot;@xsi:*&quot;/> <xsl:template match=&quot;*&quot;> <xsl:element name=&quot;{local-name}&quot; namespace=&quot;&quot;> <xsl:apply-templates select=&quot;@*&quot;/> <xsl:apply-templates /> </xsl:element> </xsl:template> <xsl:template match=&quot;@*&quot;> <xsl:attribute name=&quot;{local-name(.)}&quot; namespace=&quot;&quot;> <xsl:value-of select=&quot;.&quot;/> </xsl:attribute> </xsl:template> <xsl:template match=&quot;@xml:lang&quot;/> </xsl:stylesheet> </li> On the Tools menu, click Resource Manager in the InfoPath 2003 Form.</li> In the Resource Manager dialog box, click Add, and then locate the RemoveNamespaces.xsl file that you created in step 2.</li> On the Tools menu, click Submitting Forms.</li> Under Submit, click Submit using custom script, and then open Microsoft Script Editor.</li>  To transform the XML data of the InfoPath 2003 Form and to send the XML data to BizTalk programmatically, use code that is similar to the following code in the OnSubmitRequest event: function XDocument::OnSubmitRequest(eventObj) {  //This is the BizTalk Receive function URL. var strUrl=&quot;http://myServer/InfoPathHTTPReceive/biztalkhttpreceive.dll&quot;;

//Load the XSL transform that will remove the XML namespaces. var objStyle = new ActiveXObject(&quot;Msxml2.DOMDocument.5.0&quot;); objStyle.async = false; objStyle.load(&quot;removeNamespaces.xsl&quot;);

//Apply the XSL transform to the XML data. var newDom = new ActiveXObject(&quot;MSXML2.DOMDocument.5.0&quot;); newDom.async = false; newDom.validateOnParse = false; XDocument.DOM.transformNodeToObject(objStyle, newDom); //Post the XML document to strUrl. var objXmlHttp = new ActiveXObject(&quot;MSXML2.XMLHTTP.5.0&quot;); objXmlHttp.open(&quot;POST&quot;, strUrl, false); objXMLHttp.setRequestHeader(&quot;Content-Type&quot;, &quot;text/xml; charset=utf-16&quot;); objXmlHttp.send(newDom.xml); } </li></ol>

After you remove the XML processing instructions and the namespace declarations from the InfoPath 2003 XML file, InfoPath 2003 can no longer recognize the file as a valid InfoPath 2003 Form file. If you must open the XML data in InfoPath 2003 after you process the data in BizTalk 2002, you must re-insert the processing instructions and the namespace declarations.

Create a compiled COM component that can be called from the BizTalk Orchestration Engine component
To re-insert the processing instructions and the namespace declarations in the InfoPath 2003 XML file, create a compiled COM component that can be called from the BizTalk Orchestration Engine component. This COM component takes the unmarked XML data from BizTalk, inserts the InfoPath 2003 processing instructions in the data, and then returns the resulting XML. The processing instructions that are inserted by this COM component are specific to your particular InfoPath 2003 Form. To determine the information that you must re-insert in the InfoPath 2003 XML file, compare an XML file that was created by InfoPath 2003 with the XML data output by using the &quot;removeNamespaces.xsl&quot; transform.

<div class="status_section">

STATUS
This behavior is by design.

Keywords: kbprb KB823435

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.