Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

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.

↑ Back to the top


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.

↑ Back to the top


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

  1. Open the exported XSD schema in a text editor, such as Notepad.

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

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:
  1. Open a text editor, such as Notepad.
  2. Create a new file. Name the file RemoveNamespaces.xsl.
  3. Make sure that the RemoveNamespaces.xsl file contains the following code:
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0">
          
        <xsl:template match="@xmlns:*"/>
          
        <xsl:template match="@xsi:*"/>
          
        <xsl:template match="*">
           <xsl:element name="{local-name()}" namespace="">
              <xsl:apply-templates select="@*"/> 
              <xsl:apply-templates />
           </xsl:element>
        </xsl:template>
     
        <xsl:template match="@*">
           <xsl:attribute name="{local-name(.)}" namespace="">
              <xsl:value-of select="."/>
           </xsl:attribute>
        </xsl:template>
     
        <xsl:template match="@xml:lang"/>
    </xsl:stylesheet> 
    
  4. On the Tools menu, click Resource Manager in the InfoPath 2003 Form.
  5. In the Resource Manager dialog box, click Add, and then locate the RemoveNamespaces.xsl file that you created in step 2.
  6. On the Tools menu, click Submitting Forms.
  7. Under Submit, click Submit using custom script, and then open Microsoft Script Editor.
  8. 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="http://myServer/InfoPathHTTPReceive/biztalkhttpreceive.dll";
    
       //Load the XSL transform that will remove the XML namespaces.
       var objStyle = new ActiveXObject("Msxml2.DOMDocument.5.0");
       objStyle.async = false;
       objStyle.load("removeNamespaces.xsl");
    
       //Apply the XSL transform to the XML data.
       var newDom = new ActiveXObject("MSXML2.DOMDocument.5.0");
       newDom.async = false;
       newDom.validateOnParse = false;
       XDocument.DOM.transformNodeToObject(objStyle, newDom);
       
       //Post the XML document to strUrl.
       var objXmlHttp = new ActiveXObject("MSXML2.XMLHTTP.5.0");
       objXmlHttp.open("POST", strUrl, false);
       objXMLHttp.setRequestHeader("Content-Type", "text/xml; charset=utf-16");
       objXmlHttp.send(newDom.xml);
    }
    
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 "removeNamespaces.xsl" transform.

↑ Back to the top


Status

This behavior is by design.

↑ Back to the top


Keywords: KB823435, kbprb

↑ Back to the top

Article Info
Article ID : 823435
Revision : 2
Created on : 9/22/2011
Published on : 9/22/2011
Exists online : False
Views : 435