0

我在使用 Ksoap 解析器进行肥皂解析时收到来自服务器的响应。现在我想从对象属性中获取值。

SoapObject obj = (SoapObject)envp.getResponse(); 
System.out.println("resultsString"+obj);

现在如果我想获得RID警报总结我将如何获得

resultsStringanyType{RID=201309201377618; alertDetailPopulated=true; alertsId=0; 
alertsSummary=anyType{}; destExpArrival=06:31; destSchArrival=06:30;
destinationStation=anyType{crsCode=BKJ; stationName=Beckenham Junction; }; 
expArrival=06:19; expDepart=06:20; otherAlertPresent=false; platformNo=3;
routeDetailPopulated=false; routeDetails=null; rsID=null; schArrival=06:19; 
schDepart=06:19; serviceAlertPresent=false; toc=SE; tocName=Southeastern; trainID=2M06; trainLastReportedAt=null; }
4

2 回答 2

0
public void retrieveREsponsefromSoap(){   
  String METHOD_NAME = "GetAlldata";
  String SOAP_ACTION = "http://tempuri.org/1234.._Services/";
  SOAP_ACTION = SOAP_ACTION + METHOD_NAME;
  SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
  String SoapResult = null;

   SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
                    SoapEnvelope.VER11);
            envelope.setOutputSoapObject(request);

            envelope.dotNet = true;

            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

            // this is the actual part that will call the webservice
            androidHttpTransport.call(SOAP_ACTION, envelope);

            // Get the SoapResult from the envelope body.
            if (envelope.bodyIn instanceof SoapFault) {
                SoapResult = ((SoapFault) envelope.bodyIn).faultstring;
            } else {
                SoapObject resultsRequestSOAP = (SoapObject) envelope.bodyIn;
                SoapResult = resultsRequestSOAP.getProperty(0).toString();
            }

            Log.i(WebCalls, "Response " + SoapResult);
}
于 2013-09-20T05:30:32.100 回答
0
// Get the SoapResult from the envelope body.
        if (envelope.bodyIn instanceof SoapFault) {
            SoapResult = ((SoapFault) envelope.bodyIn).faultstring;
        } else {
            SoapObject resultsRequestSOAP = (SoapObject) envelope.bodyIn;
            SoapResult = resultsRequestSOAP.getProperty(0).toString();
        }

我希望这对你有用..

于 2013-09-20T05:33:39.707 回答