ksoap2 object parameter

"Hong Huei Tay" <[email protected]> Thu, 27 May 2004 16:56:37 +0000
Newsgroups gmane.comp.java.enhydra.ksoap
Message-ID <[email protected]>
<html><div style='background-color:'><DIV class=RTE>&nbsp;</DIV>
<DIV class=RTE>Thanks Michael for your example, but can your provide a simpler one?</DIV>
<DIV class=RTE>&nbsp;</DIV>
<DIV class=RTE>Questions:</DIV>
<DIV class=RTE>1. From my&nbsp;code example, how can it be fixed to work ?<BR>2. Can a SoapObject contain another SoapObject as a property (request parameter)?</DIV>
<DIV class=RTE>&nbsp;</DIV>
<DIV class=RTE>The codes:</DIV>
<DIV class=RTE>&nbsp;</DIV>
<DIV class=RTE>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SoapObject person = new SoapObject("urn:type-person", "person");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; person.addProperty("age", new Integer(21));<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; person.addProperty("married", new Boolean(true));<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; person.addProperty("name", "freakin");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; person.addProperty("salary", new Long(5000));
<DIV class=RTE>&nbsp;</DIV>
<DIV class=RTE>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // create soap object <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SoapObject method = new SoapObject("urn:soap-call", "echoPerson");&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; method.addProperty("person", person);</DIV>
<DIV class=RTE>&nbsp;</DIV>
<DIV class=RTE>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // create envelope<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SoapSerializationEnvelope env = new SoapSerializationEnvelope(SoapEnvelope.VER10);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; env.bodyOut = method;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </DIV>
<DIV class=RTE>&nbsp;</DIV>
<DIV class=RTE>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // create http transport to send the envelope<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; HttpTransport http = new HttpTransport&nbsp;&nbsp;&nbsp;&nbsp; ("<A href="http://localhost:8080/axis/services/EchoWebservice"><STRONG><FONT color=#002390>http://localhost:8080/axis/services/EchoWebservice</FONT></STRONG></A>");&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; http.debug = true;</DIV>
<DIV class=RTE>&nbsp;</DIV>
<DIV class=RTE><BR>this is the response dump:</DIV>
<DIV class=RTE>&nbsp;</DIV>
<DIV class=RTE>&lt;?xml version="1.0" encoding="UTF-8"?&gt;<BR>&lt;soapenv:Envelope xmlns:soapenv="<A href="http://schemas.xmlsoap.org/soap/envelope/"><STRONG><FONT color=#002390>http://schemas.xmlsoap.org/soap/envelope/</FONT></STRONG></A>" xmlns:xsd="<A href="http://www.w3.org/2001/XMLSchema"><STRONG><FONT color=#002390>http://www.w3.org/2001/XMLSchema</FONT></STRONG></A>" xmlns:xsi="<A href="http://www.w3.org/2001/XMLSchema-instance"><STRONG><FONT color=#002390>http://www.w3.org/2001/XMLSchema-instance</FONT></STRONG></A>"&gt;<BR>&nbsp;&lt;soapenv:Body&gt;<BR>&nbsp; &lt;soapenv:Fault&gt;<BR>&nbsp;&nbsp; &lt;faultcode&gt;soapenv:Server.userException&lt;/faultcode&gt;<BR>&nbsp;&nbsp; &lt;faultstring&gt;org.xml.sax.SAXException: Deserializing parameter &amp;apos;person&amp;apos;:&nbsp; could not find deserializer for type {urn:type-person}person&lt;/faultstring&gt;<BR>&nbsp;&nbsp; &lt;de
 tail/&gt;<BR>&nbsp; &lt;/soapenv:Fault&gt;<BR>&nbsp;&lt;/soapenv:Body&gt;<BR>&lt;/soapenv!
:Envelope&gt;<BR>soapenv:Server.userException</DIV>
<DIV class=RTE>&nbsp;</DIV>
<DIV class=RTE>&nbsp;</DIV>
<DIV class=RTE>I hope there's a simpler way to achieve this</DIV>
<DIV class=RTE>&nbsp;</DIV>
<DIV class=RTE>Thanks again in advance</DIV>
<DIV class=RTE>&nbsp;</DIV>
<DIV class=RTE>&nbsp;</DIV></DIV></div><br clear=all><hr>The new <a href="http://g.msn.com/8HMAEN/2737??PS=47575">MSN 8:</a> smart spam protection and 2 months FREE* </html>