2014-04-20 199 views
2

我是Android新手。 我正在使用soap的webservice,我试图匹配来自请求的数据,并希望得到回应。我在android中实现了soap演示,但没有通过标签获取数据。 我在这里粘贴肥皂的方法。如何发送请求并从android中获得响应soap

POST /InflAirBook.asmx HTTP/1.1 
Host: airwebservice.ezeeibe.com 
Content-Type: text/xml; charset=utf-8 
Content-Length: length 
SOAPAction: "InFLAirBookService/InflAirGDSLCCAvail" 

<?xml version="1.0" encoding="utf-8"?> 
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
    <soap:Body> 
    <InflAirGDSLCCAvail xmlns="InFLAirBookService"> 
     <AccountID>string</AccountID> 
     <AccountPassword>string</AccountPassword> 

    </InflAirGDSLCCAvail> 
    </soap:Body> 
</soap:Envelope> 

HTTP/1.1 200 OK Content-Type:text/xml;字符集= UTF-8 的Content-Length:长度

<?xml version="1.0" encoding="utf-8"?> 
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
    <soap:Body> 
    <InflAirGDSLCCAvailResponse xmlns="InFLAirBookService"> 
     <InflAirGDSLCCAvailResult>string</InflAirGDSLCCAvailResult> 
    </InflAirGDSLCCAvailResponse> 
    </soap:Body> 
</soap:Envelope> 

我的问题是如何解析它的Android?

请帮助我如何发送请求并从中获得响应。

在此先感谢

回答

0

我会建议为KSOAP ..这是链接https://code.google.com/p/ksoap2-android/

+0

感谢响应,但是你能告诉我我如何访问这段代码的soap body,请提供一些方法,其实我已经实现了soap demo,但没有通过标签获取数据。 – Ash

0

试试这个,我应该这将工作:

public void GetData() { 
    try{ 
    SoapObject request = new SoapObject("InFLAirBookService", 
    "InflAirGDSLCCAvail");// second parameter is your method name which you want to call 

    request.addProperty("AccountID", value1);//value1 contains value of AccountID 

    request.addProperty("AccountPassword", value2);//value2 contains value of AccountPassword 

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
      SoapEnvelope.VER11); 

    envelope.dotNet = true; 

    envelope.setOutputSoapObject(request); 

    HttpTransportSE androidHttpTransport = new 
    HttpTransportSE("airwebservice.ezeeibe.com/InflAirBook.asmx"); 


    androidHttpTransport.call("InFLAirBookService/InflAirGDSLCCAvail", 
envelope); 

    SoapPrimitive objs = (SoapPrimitive) 
envelope.getResponse();//objs will have the response from webservice in string 
//if SoapPrimitive does not work then write SoapObject. 

    } catch (Exception e) { 
     e.printStackTrace(); 
    } 
} 
} 
相关问题