繁体   English   中英

如何在Android中发送请求并获得Soap的响应

[英]How to send request and get response from soap in android

我是Android新手。 我正在使用肥皂进行网络服务,我正在尝试匹配请求中的数据并希望获得响应。 我已经在android中实现了肥皂演示,但没有通过标签获取数据。 我在这里粘贴肥皂方法。

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内容类型:text / xml; charset = utf-8内容长度:长度

<?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解析它?

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

提前致谢

我会建议使用Ksoap。这是链接https://code.google.com/p/ksoap2-android/

试试这个,我应该这样做:

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();
    }
}
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM