这是我的异步代码
@Override
protected SoapObject doInBackground(String... params) {
try {
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("ID", "0014");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
envelope.implicitTypes = false;
envelope.dotNet = true;
HttpTransportSE transport = new HttpTransportSE(URL);
try {
transport.call(SOAP_ACTION, envelope);
} catch (Exception e) {
e.printStackTrace();
}
try {
SoapFault fault = (SoapFault) envelope.bodyIn;
System.out.println("fault in getdata : " + fault);
} catch (Exception e) {
e.printStackTrace();
}
try {
result = (SoapObject) envelope.bodyIn;
System.out.println("result in getdata : " + result);
} catch (Exception e) {
e.printStackTrace();
}
} catch (Exception e) {
// System.out.println("Exception : " + e.toString());
}
return result;
}
我的回答是
result in getdata : Getesponse{GetResult=anyType{schema=anyType{element=anyType{complexType=anyType{choice=anyType
{element=anyType{complexType=anyType{sequence=anyType{element=anyType{}; element=anyType{}; element=anyType{};
element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; }; }; }; }; }; }; };
diffgram=anyType{DocumentElement=anyType{Table1=anyType{Name=Sathish1; Subject=anyType{}; ID=0014; }; }; }; }; }
我希望主题为null
而不是anyType{}
。除了使用if
语句朋友查看之外,还有更好的想法吗?
答案 0 :(得分:10)
稍后解析结果时,请使用getPrimitiveProperty
代替getProperty
。
它本质上是相同的,但修复了这种错误。
答案 1 :(得分:1)
字符串代码= soapObject.getProperty(“Code”)。toString()。replace(“anyType {}”,“”);
答案 2 :(得分:0)
要获得回复,最好使用:
SoapObject result = (SoapObject) envelope.getResponse();
或者其他方式,但您需要事先启用调试:
androidHttpsTransport.debug = true;
这是我如何打电话并得到答复:
private String makeCall(SoapSerializationEnvelope envelope) {
HttpsTransportSE mHttpsTransport = getAndroidHttpsTransport();
try {
mHttpsTransport.call(SOAP_ACTION, envelope);
} catch (IOException e) {
Logger.logError(TAG, e);
} catch (XmlPullParserException e) {
Logger.logError(TAG, e);
} finally {
Logger.logDebug(TAG, "Request dump is ");
}
return mHttpsTransport.responseDump;
}