在PropertyInfo类的setVlaue()中发送JSON对象

时间:2015-04-28 09:52:47

标签: json soap ksoap

当我在setValue()中传递字符串值时,它会完美地调用Web服务。相反,如果我传递一个JSON对象,它会显示"无法序列化"错误。我想在setValue()中发送JSON对象。有人能帮助我吗?

SoapObject request1 = new SoapObject(NAMESPACE, METHOD_NAME);
PropertyInfo unameProp = new PropertyInfo();
unameProp.setName("param");
unameProp.setValue(data);
unameProp.setType(String.class);
request1.addProperty(unameProp);
allowAllSSL.allowAllSSL();

SoapSerializationEnvelope envelope = new    SoapSerializationEnvelope(SoapEnvelope.VER11);                  
envelope.setOutputSoapObject(request1);
HttpTransportSE ht = new HttpTransportSE(URL, 20000);
ht.call(SOAP_ACTION, envelope);

1 个答案:

答案 0 :(得分:1)

在第4行中,我添加了toString()来解决问题,问题已经解决。

JSON对象:

JSONObject param = new JSONObject();
param.put("loginid", email.toString().trim());
param.put("password", password.toString().trim());

第4行:

unameProp.setValue(param.toString());