When I pass a string value in setValue()
it calls the web service perfectly. Instead, if I pass a JSON object it shows the "cannot serialize" error. I want to send the JSON object in setValue()
. Could somebody help me?
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);
In the line 4, i added toString() to solve the issue and the issue has been resolved.
JSON object:
JSONObject param = new JSONObject();
param.put("loginid", email.toString().trim());
param.put("password", password.toString().trim());
line 4 :
unameProp.setValue(param.toString());