在 SOAP 响应中包含 XML [英] Include XML in SOAP response

查看:23
本文介绍了在 SOAP 响应中包含 XML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 WSDL 中,我将其设置为如下所示:

In my WSDL my reponse I have it setup to be like this:

<message name='getPartsResponse'>
  <part name='Result' type='xsd:string'/>
</message>

我遇到的问题是我在响应中发送的是 XML 而不是字符串.因此,我使用 HTML 实体而不是 < 获取响应的 XML(不是 XML SOAP 响应(可以))和 > XML 有.

The problem I am having is that what I am sending in the response is XML and not an string. As a result of this I am getting the XML of the response (not the XML SOAP Response (that is ok)) with HTML entities instead of the < and > XML has.

这是我得到的:

<SOAP-ENV:Body>
<ns1:getPartsResponse>
<Result xsi:type="xsd:string">
&lt ;catalog&gt ;
&lt ;result id="1"&gt ;
&lt ;part&gt ;AAAAAAAAAAA&lt ;/part&gt ;
&lt ;qty>0000000000&lt ;/qty&gt ;
&lt ;mfg&gt ;XXXXXXXXXXXXX&lt ;/mfg&gt ;
&lt ;/result&gt ;
&lt ;result id="2"&gt ;
&lt ;part&gt ;BBBBBBBBBBB&lt ;/part&gt ;
&lt ;qty>11111111111&lt ;/qty&gt ;
&lt ;mfg&gt ;ZZZZZZZZZZZZZ&lt ;/mfg&gt ;
&lt ;/result&gt ;
&lt ;/catalog&gt ;
</Result>
</ns1:getPartsResponse>
</SOAP-ENV:Body>

这就是我想要的:

<SOAP-ENV:Body>
<ns1:getPartsResponse>
<Result xsi:type="xsd:string">
<catalog>
<result id="1">
<part>AAAAAAAAAAA</part>
<qty>0000000000</qty>
<mfg>XXXXXXXXXXXXX</mfg>
</result>
<result id="2">
<part>BBBBBBBBBBB</part>
<qty>11111111111</qty>
<mfg>ZZZZZZZZZZZZZ</mfg>
</result>
</catalog>
</Result>
</ns1:getPartsResponse>
</SOAP-ENV:Body>

我错过了什么?

谢谢.

推荐答案

除非服务的架构准确地描述了您尝试发送的 XML,否则您必须使用 XML 转义使您的 XML 作为字符串通过管道.&lt;tag&gt; 而不是 等等等等

Unless the schema for the service describes exactly the XML you are trying to send, you have to use XML escapes to make your XML pass through the pipe as a string. &lt;tag&gt; instead of <tag>, etc, etc, etc.

或者,您需要更改架构以使用 XML 架构 any 粒子.

Or, you need to change the schema to use an XML schema any particle.

如果这对您来说是全新的,我建议您下载 Apache CXF 的发行版.查看wsdl-first"示例,了解架构是如何集成的.

If this is all new to you, I recommend downloading a distribution of Apache CXF. Look at the 'wsdl-first' examples and see how the schema is integrated.

这篇关于在 SOAP 响应中包含 XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆