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">
< ;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>
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. <tag>
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.
精彩评论