我已使用以下代码从.Net Web服务(asmx)获取响应。

try{
    SoapObject request = new SoapObject(NAMESPACE,METHOD_NAME);
        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.dotNet =true;
    AndroidHttpTransport httpTransport = new AndroidHttpTransport(URL);
        envelope.setOutputSoapObject(request);
    httpTransport.debug=true;
        httpTransport.call(SOAP_ACTION, envelope);
    SoapObject result=(SoapObject)envelope.getResponse();
    String Text = result.getProperty(1).toString();
        System.out.println("Text : "  + Text);
    }
catch (Exception e) {
    e.printStackTrace();
}


当我尝试此代码时,得到以下输出。


  anyType {NewDataSet = anyType {ResponseTable = anyType {Result = Success; }; };
  }


在这里,我需要“结果=成功”。

请帮我。

最佳答案

尝试:

SoapObject result = (SoapObject)envelope.bodyIn;
String Result = result.getProperty(0).toString();

关于android - 如何从Soap Object获取响应到Android中的字符串?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/19381009/

10-10 08:14