Java HTTP GET方法到android中的SOAP,请更正我
我正在使用Web服务。我使用了HTTP GET来实现所有功能。但是这个功能需要发送一个很长的XML,这使得查询长度的问题变得很长。我知道该服务还支持SOAP1.1、1.2 但我从来没有用过肥皂,我不知道该怎么做。我在谷歌上找到了一些例子。 我试着为我使用。请注意,我正试图通过此页面转换 这是我正在使用的HTTP GET URL,希望用SOAP替换它 HTTP获取 对此Java HTTP GET方法到android中的SOAP,请更正我,java,android,http,soap,get,Java,Android,Http,Soap,Get,我正在使用Web服务。我使用了HTTP GET来实现所有功能。但是这个功能需要发送一个很长的XML,这使得查询长度的问题变得很长。我知道该服务还支持SOAP1.1、1.2 但我从来没有用过肥皂,我不知道该怎么做。我在谷歌上找到了一些例子。 我试着为我使用。请注意,我正试图通过此页面转换 这是我正在使用的HTTP GET URL,希望用SOAP替换它 HTTP获取 对此 POST /WsServices/WsServices.asmx HTTP/1.1 Host: 200.26.174.211
POST /WsServices/WsServices.asmx HTTP/1.1
Host: 200.26.174.211
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/PagoFactura"
<?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>
<PagoFactura xmlns="http://tempuri.org/">
<AppUsuario>string</AppUsuario>
<AppPassword>string</AppPassword>
<Usuario>string</Usuario>
<Password>string</Password>
<monto>decimal</monto>
<cantidadFacturas>int</cantidadFacturas>
<IdEmpresaServicio>int</IdEmpresaServicio>
<IdUsuarioEmpresaServicio>int</IdUsuarioEmpresaServicio>
<IdCuenta>int</IdCuenta>
<cvv>string</cvv>
<xmlFacturas>string</xmlFacturas>
</PagoFactura>
</soap:Body>
</soap:Envelope>
下面是一个很好的视频教程,介绍如何使用k-soap处理Web服务:
正是我想要的。谢谢
POST /WsServices/WsServices.asmx HTTP/1.1
Host: 200.26.174.211
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/PagoFactura"
<?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>
<PagoFactura xmlns="http://tempuri.org/">
<AppUsuario>string</AppUsuario>
<AppPassword>string</AppPassword>
<Usuario>string</Usuario>
<Password>string</Password>
<monto>decimal</monto>
<cantidadFacturas>int</cantidadFacturas>
<IdEmpresaServicio>int</IdEmpresaServicio>
<IdUsuarioEmpresaServicio>int</IdUsuarioEmpresaServicio>
<IdCuenta>int</IdCuenta>
<cvv>string</cvv>
<xmlFacturas>string</xmlFacturas>
</PagoFactura>
</soap:Body>
</soap:Envelope>
private static final String SOAP_ACTION = "myMethod";
private static final String METHOD_NAME = "myMethod";
private static final String NAMESPACE = "http://mynamespace.com/";
private static final String URL = "http://myserver.com/bean";
void test() {
try {
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("prop1", "myprop");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.call(SOAP_ACTION, envelope);
Object result = envelope.getResponse();
//handle result here
myExampleHandler.getResults();
} catch (Exception e) {
e.printStackTrace();
}
}