RE: ksoap 2 object parameters

"McCune, Michael" <[email protected]> Thu, 27 May 2004 12:35:01 -0400
Newsgroups gmane.comp.java.enhydra.ksoap
Message-ID <1972F96CB40DD647B2E0B38BE7960E74054096FA@tayexc17.americas.cpqcorp.net>
This is a multi-part message in MIME format.

------_=_NextPart_001_01C44408.8E7DDEC1
Content-Type: multipart/alternative;
	boundary="----_=_NextPart_002_01C44408.8E7DDEC1"


------_=_NextPart_002_01C44408.8E7DDEC1
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Here is how I published a service (AlertService is attached) that takes =
multiple parameters:
AlertService alertService =3D new AlertService();

publishInstance( "AlertService", alertService );

PropertyInfo[] propInfoNonAttach =3D new PropertyInfo[2];

PropertyInfo propInfoNon0 =3D new PropertyInfo();

PropertyInfo propInfoNon1 =3D new PropertyInfo();

propInfoNon0.type =3D PropertyInfo.BOOLEAN_CLASS;

propInfoNon0.name =3D "returnTimeWithAlert";

propInfoNon1.type =3D PropertyInfo.STRING_CLASS;

propInfoNon1.name =3D "testString";

propInfoNonAttach[0] =3D propInfoNon0;

propInfoNonAttach[1] =3D propInfoNon1;

publishMethod( =
alertService.getClass(),"urn:system-alert","getNextSystemAlert",propInfoN=
onAttach );

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D

I ended up having to make a fix in the kSOAP2 code to get it to work =
this way...let me know if you still run into problems.

-Mike

=20

-----Original Message-----
From: [email protected] [mailto:[email protected]]On Behalf =
Of Hong Huei Tay
Sent: Thursday, May 27, 2004 12:20 PM
To: [email protected]
Subject: Ksoap: ksoap 2 object parameters


Hi,
=20
Has anyone tried sending complex objects as parameters using kSOAP 2 =
(not kSOAP 1.2) ?=20
=20
Here is a section of my code:
=20
            SoapObject person =3D new SoapObject("urn:type-person", =
"person");
            person.addProperty("age", new Integer(21));
            person.addProperty("married", new Boolean(true));
            person.addProperty("name", "freakin");
            person.addProperty("salary", new Long(5000));
=20
            // create soap object=20
            SoapObject method =3D new SoapObject("urn:soap-call", =
"echoPerson");           =20
            method.addProperty("person", person);
=20
            // create envelope
            SoapSerializationEnvelope env =3D new =
SoapSerializationEnvelope(SoapEnvelope.VER10);
            env.bodyOut =3D method;           =20
=20
            // create http transport to send the envelope
            HttpTransport http =3D new HttpTransport     (" =
http://localhost:8080/axis/services/EchoWebservice");     =20
            http.debug =3D true;
=20

this is the response dump:
=20
<?xml version=3D"1.0" encoding=3D"UTF-8"?>
<soapenv:Envelope xmlns:soapenv=3D" =
http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd=3D" =
http://www.w3.org/2001/XMLSchema" xmlns:xsi=3D" =
http://www.w3.org/2001/XMLSchema-instance">
 <soapenv:Body>
  <soapenv:Fault>
   <faultcode>soapenv:Server.userException</faultcode>
   <faultstring>org.xml.sax.SAXException: Deserializing parameter =
&apos;person&apos;:  could not find deserializer for type =
{urn:type-person}person</faultstring>
   <detail/>
  </soapenv:Fault>
 </soapenv:Body>
</soapenv:Envelope>
soapenv:Server.userException
=20

Can someone help me out?=20
=20
Thanks in advance
=20
=20

  _____ =20

Tired of spam? Get advanced  <http://g.msn.com/8HMAEN/2734??PS=3D47575> =
junk mail protection with MSN 8. =
_______________________________________________ Ksoap mailing list =
[email protected] http://www.enhydra.org/mailman/listinfo.cgi/ksoap=20


------_=_NextPart_002_01C44408.8E7DDEC1
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">


<META content=3D"MSHTML 6.00.2800.1400" name=3DGENERATOR></HEAD>
<BODY>
<DIV><SPAN class=3D585105216-27052004><FONT face=3DArial color=3D#0000ff =
size=3D2>Here=20
is how I published a service (AlertService is attached)&nbsp;that takes =
multiple=20
parameters:</FONT></SPAN></DIV>
<DIV><SPAN class=3D585105216-27052004><FONT size=3D2>
<P>AlertService alertService =3D </FONT><B><FONT color=3D#7f0055=20
size=3D2>new</B></FONT><FONT size=3D2> AlertService();</P>
<P>publishInstance( </FONT><FONT color=3D#2a00ff =
size=3D2>"AlertService"</FONT><FONT=20
size=3D2>, alertService );</P>
<P></P>
<P></P>
<P>PropertyInfo[] propInfoNonAttach =3D </FONT><B><FONT color=3D#7f0055=20
size=3D2>new</B></FONT><FONT size=3D2> PropertyInfo[2];</P>
<P>PropertyInfo propInfoNon0 =3D </FONT><B><FONT color=3D#7f0055=20
size=3D2>new</B></FONT><FONT size=3D2> PropertyInfo();</P>
<P>PropertyInfo propInfoNon1 =3D </FONT><B><FONT color=3D#7f0055=20
size=3D2>new</B></FONT><FONT size=3D2> PropertyInfo();</P>
<P></P>
<P>propInfoNon0.type =3D PropertyInfo.BOOLEAN_CLASS;</P>
<P>propInfoNon0.name =3D </FONT><FONT color=3D#2a00ff=20
size=3D2>"returnTimeWithAlert"</FONT><FONT size=3D2>;</P>
<P></P>
<P>propInfoNon1.type =3D PropertyInfo.STRING_CLASS;</P>
<P>propInfoNon1.name =3D </FONT><FONT color=3D#2a00ff=20
size=3D2>"testString"</FONT><FONT size=3D2>;</P>
<P></P>
<P>propInfoNonAttach[0] =3D propInfoNon0;</P>
<P>propInfoNonAttach[1] =3D propInfoNon1;</P>
<P></P>
<P>publishMethod( alertService.getClass(),</FONT><FONT color=3D#2a00ff=20
size=3D2>"urn:system-alert"</FONT><FONT size=3D2>,</FONT><FONT =
color=3D#2a00ff=20
size=3D2>"getNextSystemAlert"</FONT><FONT size=3D2>,propInfoNonAttach =
);</FONT></P>
<P><SPAN class=3D585105216-27052004><FONT=20
size=3D2>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D</FONT></SPAN></P>
<P><SPAN class=3D585105216-27052004><FONT face=3DArial color=3D#0000ff =
size=3D2>I ended=20
up having to make a fix in the kSOAP2 code to get it to work this =
way...let me=20
know if you still run into problems.</FONT></SPAN></P>
<P><SPAN class=3D585105216-27052004><FONT face=3DArial color=3D#0000ff=20
size=3D2>-Mike</FONT></SPAN></P>
<P><FONT size=3D2><FONT face=3DArial=20
color=3D#0000ff></FONT>&nbsp;</P></FONT></SPAN></DIV>
<BLOCKQUOTE>
  <DIV class=3DOutlookMessageHeader dir=3Dltr align=3Dleft><FONT =
face=3DTahoma=20
  size=3D2>-----Original Message-----<BR><B>From:</B> =
[email protected]=20
  [mailto:[email protected]]<B>On Behalf Of </B>Hong Huei=20
  Tay<BR><B>Sent:</B> Thursday, May 27, 2004 12:20 PM<BR><B>To:</B>=20
  [email protected]<BR><B>Subject:</B> Ksoap: ksoap 2 object=20
  parameters<BR><BR></FONT></DIV>
  <DIV>
  <DIV class=3DRTE>Hi,</DIV>
  <DIV class=3DRTE><FONT face=3DArial color=3D#0000ff =
size=3D2></FONT>&nbsp;</DIV>
  <DIV class=3DRTE>Has anyone tried sending complex objects as =
parameters using=20
  kSOAP 2 (not kSOAP 1.2) ? </DIV>
  <DIV class=3DRTE>&nbsp;</DIV>
  <DIV class=3DRTE>Here is a section of my code:</DIV>
  <DIV class=3DRTE>&nbsp;</DIV>
  <DIV=20
  =
class=3DRTE>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;=20
  SoapObject person =3D new SoapObject("urn:type-person",=20
  =
"person");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;=20
  person.addProperty("age", new=20
  =
Integer(21));<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;=20
  person.addProperty("married", new=20
  =
Boolean(true));<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;=20
  person.addProperty("name",=20
  =
"freakin");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;=20
  person.addProperty("salary", new Long(5000));</DIV>
  <DIV class=3DRTE>&nbsp;</DIV>
  <DIV=20
  =
class=3DRTE>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;=20
  // create soap object=20
  <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =

  SoapObject method =3D new SoapObject("urn:soap-call",=20
  =
"echoPerson");&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;=20
  method.addProperty("person", person);</DIV>
  <DIV class=3DRTE>&nbsp;</DIV>
  <DIV=20
  =
class=3DRTE>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;=20
  // create=20
  =
envelope<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;=20
  SoapSerializationEnvelope env =3D new=20
  =
SoapSerializationEnvelope(SoapEnvelope.VER10);<BR>&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
  env.bodyOut =3D=20
  =
method;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
=20
  </DIV>
  <DIV class=3DRTE>&nbsp;</DIV>
  <DIV=20
  =
class=3DRTE>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;=20
  // create http transport to send the=20
  =
envelope<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;=20
  HttpTransport http =3D new HttpTransport&nbsp;&nbsp;&nbsp;&nbsp; ("<A=20
  =
href=3D"http://localhost:8080/axis/services/EchoWebservice">http://localh=
ost:8080/axis/services/EchoWebservice</A>");&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;=20
  <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =

  http.debug =3D true;</DIV>
  <DIV class=3DRTE>&nbsp;</DIV>
  <DIV class=3DRTE><BR>this is the response dump:</DIV>
  <DIV class=3DRTE>&nbsp;</DIV>
  <DIV class=3DRTE>&lt;?xml version=3D"1.0"=20
  encoding=3D"UTF-8"?&gt;<BR>&lt;soapenv:Envelope xmlns:soapenv=3D"<A=20
  =
href=3D"http://schemas.xmlsoap.org/soap/envelope/">http://schemas.xmlsoap=
.org/soap/envelope/</A>"=20
  xmlns:xsd=3D"<A=20
  =
href=3D"http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchem=
a</A>"=20
  xmlns:xsi=3D"<A=20
  =
href=3D"http://www.w3.org/2001/XMLSchema-instance">http://www.w3.org/2001=
/XMLSchema-instance</A>"&gt;<BR>&nbsp;&lt;soapenv:Body&gt;<BR>&nbsp;=20
  &lt;soapenv:Fault&gt;<BR>&nbsp;&nbsp;=20
  =
&lt;faultcode&gt;soapenv:Server.userException&lt;/faultcode&gt;<BR>&nbsp;=
&nbsp;=20
  &lt;faultstring&gt;org.xml.sax.SAXException: Deserializing parameter=20
  &amp;apos;person&amp;apos;:&nbsp; could not find deserializer for type =

  {urn:type-person}person&lt;/faultstring&gt;<BR>&nbsp;&nbsp;=20
  &lt;detail/&gt;<BR>&nbsp;=20
  =
&lt;/soapenv:Fault&gt;<BR>&nbsp;&lt;/soapenv:Body&gt;<BR>&lt;/soapenv:Env=
elope&gt;<BR>soapenv:Server.userException</DIV>
  <DIV class=3DRTE>&nbsp;</DIV>
  <DIV class=3DRTE><BR>Can someone help me out? </DIV>
  <DIV class=3DRTE>&nbsp;</DIV>
  <DIV class=3DRTE>Thanks in advance</DIV>
  <DIV class=3DRTE>&nbsp;</DIV>
  <DIV class=3DRTE>&nbsp;</DIV></DIV><BR clear=3Dall>
  <HR>
  Tired of spam? Get <A =
href=3D"http://g.msn.com/8HMAEN/2734??PS=3D47575">advanced=20
  junk mail protection</A> with MSN 8.=20
  _______________________________________________ Ksoap mailing list=20
  [email protected] http://www.enhydra.org/mailman/listinfo.cgi/ksoap=20
</BLOCKQUOTE></BODY></HTML>

------_=_NextPart_002_01C44408.8E7DDEC1--

------_=_NextPart_001_01C44408.8E7DDEC1
Content-Type: application/octet-stream;
	name="AlertService.java"
Content-Transfer-Encoding: base64
Content-Description: AlertService.java
Content-Disposition: attachment;
	filename="AlertService.java"

cGFja2FnZSBjb20uaHAuc3VwcG9ydC5rc29hcDIuZXhhbXBsZTsNCg0KDQpwdWJsaWMgY2xhc3Mg
QWxlcnRTZXJ2aWNlDQp7DQogICAgLy9pZiB0aGUgc2VydmljZSBtZXRob2QgaXMgb3ZlcmxvYWRl
ZCwgdGhlIGZpcnN0IG9uZSBmb3VuZCBpbiB0aGUgY2xhc3Mgd2lsbCBiZSB1c2VkLA0KICAgIC8v
YW5kIHRoZSByZXN0IGFyZSBpZ25vcmVkDQogICAgDQoNCiAgICBwdWJsaWMgQWxlcnRTZXJ2aWNl
KCkgeyB9DQoNCiAgICBwdWJsaWMgU3RyaW5nIGdldE5leHRTeXN0ZW1BbGVydCggQm9vbGVhbiBy
ZXR1cm5UaW1lV2l0aEFsZXJ0LCBTdHJpbmcgdGVzdFN0cmluZyApDQogICAgew0KICAgICAgICAN
CiAgICAgICAgU3RyaW5nQnVmZmVyIHNCdWZmZXIgPSBuZXcgU3RyaW5nQnVmZmVyKCk7DQogICAg
ICAgIA0KICAgICAgICBpZiAoIHJldHVyblRpbWVXaXRoQWxlcnQuYm9vbGVhblZhbHVlKCkgKQ0K
ICAgICAgICB7DQogICAgICAgICAgICBzQnVmZmVyLmFwcGVuZCggU3lzdGVtLmN1cnJlbnRUaW1l
TWlsbGlzKCkgKTsNCiAgICAgICAgfQ0KICAgICAgICBzQnVmZmVyLmFwcGVuZCggIjogU2FtcGxl
IEVycm9yIE1lc3NhZ2UiKTsNCiAgICAgICAgDQogICAgICAgIHJldHVybiBzQnVmZmVyLnRvU3Ry
aW5nKCk7DQogICAgfQ0KDQp9DQo=

------_=_NextPart_001_01C44408.8E7DDEC1--