1

这是我的异步代码

@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除了使用语句朋友检查之外,还有什么更好的主意吗?

4

3 回答 3

11

当您稍后解析结果时,请使用getPrimitiveProperty而不是getProperty. 它本质上是相同的,但修复了这种错误。

于 2013-08-23T11:02:17.723 回答
1

String code = soapObject.getProperty("Code").toString().replace("anyType{}", "");

于 2016-10-02T17:24:14.293 回答
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;
}
于 2013-08-23T10:42:25.257 回答