I consume a WCF service in Biztalk with the wizard "Add generated Items -> Consume WCF Service"

The problem I have is the service is returning a response that can't be parsed: Reason: An error occurred when parsing the incoming document: "There are multiple root elements. Line 1, position 296."

That's surprising since I'm using the autogenerated schemas

But is not an Error message since the service makes the expected operation, the problem I think has to do with the multiRef tag

Response:

<ns1:sendSmsSubmissionResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://mobicomp.com/smsexpress/webservice/server/message">
    <sendSmsSubmissionReturn href="#id0" /> 
</ns1:sendSmsSubmissionResponse>
<multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns2:SubmissionStatus" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="http://mobicomp.com/smsexpress/webservice/server/message">
    <id xsi:type="soapenc:string">4336723</id> 
    <message xsi:type="soapenc:string">Submissão enviada para processamento.</message> 
    <status href="#id1" /> 
</multiRef>
<multiRef id="id1" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="xsd:int" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">0</multiRef> 

Schema

<xs:schema xmlns:tns="http://mobicomp.com/smsexpress/webservice/server/message" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://mobicomp.com/smsexpress/webservice/server/message" id="sendSmsSubmissionResponse" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:include schemaLocation=".\SubmissionManagerService_mobicomp_com_smsexpress_webservice_server_message.xsd" /> 
    <xs:annotation>
        <xs:appinfo>
            <schemaInfo root_reference="sendSmsSubmissionResponse" xmlns="http://schemas.microsoft.com/BizTalk/2003" /> 
            <b:references>
                <b:reference targetNamespace="http://common.server.webservice.smsexpress.mobicomp.com" /> 
                <b:reference targetNamespace="http://mobicomp.com/smsexpress/webservice/server/message" /> 
                <b:reference targetNamespace="http://schemas.xmlsoap.org/soap/encoding/" /> 
            </b:references>
        </xs:appinfo>
    </xs:annotation>
    <xs:element name="sendSmsSubmissionResponse">
        <xs:annotation>
            <xs:documentation>Wrapper element for message "sendSmsSubmissionResponse" of RPC operation "sendSmsSubmission".</xs:documentation> 
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:element name="sendSmsSubmissionReturn" type="tns:SubmissionStatus" /> 
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>

What can I do in order I don't get this error?

thanks!

EDIT:

Specifying in the schema the root reference to be "sendSmsSubmissionResponse" didn't solve the issue

有帮助吗?

解决方案

Ok I solved it

I'm going to write it down just it case somebody runs in the same problem

I created a custom receive pipeline in which:

Decode, first transform the XML in an standard onw with an XSL Dissasemble to remove soap Envelope and just leave body

Then biztalk accepts the XML message and I proceed normally

The XSL I used is the one I found here but tweaked:

<xsl:stylesheet version="1.0"
            xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
            xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" >

<xsl:key name="multiref-by-id" match="multiRef" use="@id"/>

<xsl:template match="/">
    <xsl:copy>
        <xsl:apply-templates select="@*|*"/>
    </xsl:copy>
</xsl:template>

<xsl:template match="*[starts-with(@href, '#')]">
    <xsl:copy>
        <xsl:apply-templates select="@* |
         key('multiref-by-id', substring-after(@href, '#'))/@*[not(local-name()='id' or local-name()='type')] |
        key('multiref-by-id', substring-after(@href, '#'))/node()"/>
    </xsl:copy>
</xsl:template>

<xsl:template match="@href[starts-with(., '#')] | multiRef[@id] | @soapenc:root"/>

<xsl:template match="@*|node()">
    <xsl:copy>
        <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
</xsl:template>

其他提示

You can only have a single root element in BizTalk message processing. There are multiple ways to do this, but essentially you need to debatch each repeated root in the message so that it can be processed separately or create a wrapper element to allow it to be processed. This type of component would have to exist in the pipelining stage (custom pipeline).

You can also treat the message as XML and parse it depending on the size and whether you need it indexed.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top