简体   繁体   中英

How to pass an object as parameter from android to web service using ksoap2

I'm trying to send object as parameter to web service on java. It always throws a Runtime exception with Cannot serialize what is the best way to do that thx in advance

使用Ksoap2查看这个复杂对象基本上,您唯一需要做的就是实现KvmSerializable接口。

Like as Ksoap2's page in google code, CodingTipsAndTricks part: To get this xml:

<users>
  <user>
     <name>Jonh</name>
     <age>12</age>
  </user>
  <user>
     <name>Marie</name>
     <age>27</age>
  </user>
</users>

You would do this:

SoapObject users = new SoapObject(NAMESPACE, "users");
SoapObject john = new SoapObject(NAMESPACE, "user");
john.addProperty("name", "john");
john.addProperty("age", 12);
SoapObject marie = new SoapObject(NAMESPACE, "user");
john.addProperty("name", "marie");
john.addProperty("age", 27);
users.addSoapObject(john);
users.addSoapObject(marie);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM