[英]How to send request and get response from soap in android
I am new in Android. 我是Android新手。 I am working on webservice using soap, I am trying to match data from request and want to get response. 我正在使用肥皂进行网络服务,我正在尝试匹配请求中的数据并希望获得响应。 I have implemented soap demo in android but not getting data through tag. 我已经在android中实现了肥皂演示,但没有通过标签获取数据。 I am pasting soap method here. 我在这里粘贴肥皂方法。
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; HTTP / 1.1 200 OK内容类型:text / xml; charset=utf-8 Content-Length: length 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>
My Question is how to parse it for Android ? 我的问题是如何为Android解析它?
Please help me how to send request and get response from it. 请帮助我如何发送请求并从中获取响应。
Thanks in advance 提前致谢
我会建议使用Ksoap。这是链接https://code.google.com/p/ksoap2-android/
try this i should this will work : 试试这个,我应该这样做:
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.