【发布时间】:2013-12-27 05:46:51
【问题描述】:
我正在使用下面的代码在soap webservice响应中获取JSON
SoapSerializationEnvelope envelope = new new SoapSerializationEnvelope(SoapEnvelope.VER11);
try {
SOAP_ACTION = namespace + MethodName;
//Adding values to request object
request = new SoapObject(namespace, MethodName);
//Adding Double value to request object
PropertyInfo weightProp =new PropertyInfo();
//Adding String value to request object
request.addProperty("myParam1", "" + myParam1);
request.addProperty("myParam2", "" + myParam2);
SetEnvelope(url);
try {
//SOAP calling webservice
androidHttpTransport.call(SOAP_ACTION, envelope);
//Got Webservice response
SoapObject res = (SoapObject) envelope.getResponse();
return Integer.parseInt(res);
} catch (Exception e) {
return -1;
//return 0;
}
} catch (Exception e) {
return -1;
//return 2;
}
作为回应,我的 Json 数据是
({"result":"123456" })
然后我在线检查了我的Json,它是错误的然后我转换了我的JSON数据
{"result":"123456" }
但在这两种情况下,我都得到了 例外
12-27 13:49:58.905: I/Webservice(2196): unexpected type (position:TEXT [{"result":"" }]@1:16 in java.io.InputStreamReader@406d5c48)
【问题讨论】:
-
请发布完整的堆栈跟踪。另外,
enveloppe是什么,SoapObject是什么? -
在堆栈跟踪中,我在 SoapSerializable 中收到了意外令牌和信封的异常,我已经编辑了我的问题。
-
我有点困惑,我是在 json 中得到正确的响应还是格式不正确
-
12-27 13:49:58.905: I/Webservice(2196): 意外类型(位置:TEXT [{"result":"" }]@1:16 in java.io.InputStreamReader @406d5c48)
标签: java android json web-services soap