问题描述
我在Biztalk中使用向导添加生成的项目-> 使用WCF服务"
I consume a WCF service in Biztalk with the wizard "Add generated Items -> Consume WCF Service"
我遇到的问题是服务正在返回无法解析的响应:原因:分析传入文档时发生错误:存在多个根元素.第1行,位置296."
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
但不是错误消息,因为该服务已完成预期的操作,我认为该问题与multiRef标记有关
But is not an Error message since the service makes the expected operation, the problem I think has to do with the multiRef tag
响应:
<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>
模式
<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?
谢谢!
在架构中将根引用指定为"sendSmsSubmissionResponse"并不能解决问题
Specifying in the schema the root reference to be "sendSmsSubmissionResponse" didn't solve the issue
推荐答案
好,我解决了
我要把它写下来,以防万一有人遇到同样的问题
I'm going to write it down just it case somebody runs in the same problem
我创建了一个自定义接收管道,其中:
解码,首先使用XSL将XML转换为标准onw不方便去除肥皂信封,只是离开身体
Decode, first transform the XML in an standard onw with an XSLDissasemble to remove soap Envelope and just leave body
然后biztalk接受XML消息,我可以正常进行
Then biztalk accepts the XML message and I proceed normally
我使用的XSL是我在此处但进行了调整:
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>
这篇关于Biztalk-SOAP响应包含多引用,因此无法处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!