You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-user@ws.apache.org by Andrew Parkin <An...@eigroup.com> on 2001/01/22 09:15:35 UTC
Newbie question on deserializing structs
Please excuse me if this is really dumb, but I have only just starting
playing with SOAP.
I have managed to make a SOAP call and pick up the single string returned by
the call, but keep getting an error when I try to call methods that return
"structs". If the following XML is returned from the SOAP server, I can
pick up the return value of "some text".
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema/instance/"
xmlns:xsd="http://www.w3.org/1999/XMLSchema/">
<SOAP-ENV:Body>
<ns1:submitMessageResponse xmlns:ns1="urn:myTest"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<return xsi:type="xsd:string">some Text</return>
</ns1:submitMessageResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
However, if I try and pick up the response when the following XML is
returned, I get the message "[SOAPException: faultCode=SOAP-ENV:Client;
msg=No Deserializer found to deserialize a
'http://www.w3.org/1999/XMLSchema/:SOAP-ENC:Struct' using encoding style
'http://schemas.xmlsoap.org/soap/encoding/'.;
targetException=java.lang.IllegalArgumentException: No Deserializer found to
deserialize a 'http://www.w3.org/1999/XMLSchema/:SOAP-ENC:Struct' using
encoding style 'http://schemas.xmlsoap.org/soap/encoding/'.]"
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema/instance/"
xmlns:xsd="http://www.w3.org/1999/XMLSchema/">
<SOAP-ENV:Body>
<ns1:submitMessageResponse xmlns:ns1="urn:myTest"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<messageDetails xsi:type="xsd:SOAP-ENC:Struct">
<Addr xsi:type="xsd:string">12345</messageDestAddr>
<Body xsi:type="xsd:string">some Text</messageBody>
</messageDetails>
</ns1:submitMessageResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Here is the code. I'm sure I need to describe how to deserialize the
structure somehow, but I can't find any examples anywhere showing how to to
this. I have tried the XMLParameterSerializer with no luck. Also, I am
unsure whether the XML is correct where it describes the Struct tag.
The Address Book sample is not particularly useful as I only want to pick up
the XML, not convert it into a Java Bean. Any help would be much
appreciated as I have been tearing my hair out trying to get this to work.
Many thanks.
SOAPMappingRegistry smr = new SOAPMappingRegistry();
XMLParameterSerializer xmlSer = new XMLParameterSerializer();
smr.mapTypes(Constants.NS_URI_LITERAL_XML,new QName("urn:myTest",
"http://www.w3.org/1999/XMLSchema/:SOAP-ENC:Struct"),
org.w3c.dom.Element.class, xmlSer, xmlSer);
Call call = new Call();
call.setTargetObjectURI("urn:myTest");
call.setMethodName("submitMessage");
call.setEncodingStyleURI(Constants.NS_URI_LITERAL_XML);
Vector params = new Vector();
params.addElement(new Parameter("testParam", String.class, "testing",
null));
call.setParams(params);
Response resp = call.invoke (soapServerURL, "");