如何解决在Android中通过ksoap2发送和接收复杂数据[序列化错误]
| 好吧,我有一台具有方法的服务器 收到MonitorRequest(可序列化对象) 返回MonitorResponse [](可序列化的对象) 每个MonitorResponse都包含一个MonitorDetail,其中包含我需要的信息。 码:class MonitorDetail implements Serializable{
String name;
//Long,Short,String (...)
}
class MonitorResponse implements Serializable{
Short returnCode;
MonitorDetail monitorCodeList; //the request can request more than 1 monitor info.
String user;
}
class MonitorRequest implements Serializable {
Integer storeCode;
Short categoryCode;
Long[] monitorCodeList; //here I post the code of the monitors I need
String user;
//getters and setters
}
所以,这是我的问题:
我无法更改服务器中那些对象的定义,所以我该如何
进行此通信时不会出现“无法序列化错误”的信息。
我如何发送ProductRequest,接收ProductResponse []和
通过KSOAP2获得特定的ProductDetail?
我试过了:
SoapObject request = new SoapObject(NAMESPACE,OPERATION);
request.addProperty(PROPERTY,getProductConfiguredMonitorRequest());
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
HttpTransportSE httpTransport = new HttpTransportSE(URL);
enter code here
try {
httpTransport.call(\"\",envelope);
SoapObject result = (SoapObject) envelope.bodyIn;
return extractMonitorDetailFromresult(result);
} catch (Exception e) {
/* a lot of stuff */
return null;
}
return null;
那么,我该如何进行交流?
解决方法
在信封而不是bodyIn上获得getResponse,然后解析循环获得的SoapObject。
更多信息请访问
http://code.google.com/p/ksoap2-android/wiki/CodingTipsAndTricks
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。