开发者

Include XML in SOAP response

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

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

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.

This is what I get:

<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>

And this is what I want to get:

<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">开发者_StackOverflow
<part>BBBBBBBBBBB</part>
<qty>11111111111</qty>
<mfg>ZZZZZZZZZZZZZ</mfg>
</result>
</catalog>
</Result>
</ns1:getPartsResponse>
</SOAP-ENV:Body>

What am I missing?

Thank you.


Below worked for me in perl

use XML::Entities;

$b = XML::Entities::decode('all', $response);
print $b;

$response should be the XML that was returned by the webservice call.


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.

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

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.


Why did you specify the type of the message part was xsd:string? It should have been specified as xsd:any or as a specific type defined in your schema. Then you could include it inline.

You are seeing precisely what you asked the computer to do.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜