gpt4 book ai didi

java - Android中SOAP的HTTP GET方法,请纠正我

转载 作者:行者123 更新时间:2023-12-02 08:12:39 24 4
gpt4 key购买 nike

我正在使用网络服务。我已使用 HTTP GET 来实现所有功能。但此功能需要发送很长的 XML,这会导致查询长度太长。我知道该服务还支持 SOAP 1.1 , 1.2但我从未使用过 SOAP,我很困惑如何做到这一点。我用谷歌搜索并找到了一些例子。我正在尝试使用 Example 为我。请我尝试通过此页面进行转换

http://200.26.174.211/WsServices/WsServices.asmx?op=PagoFactura

这是我正在使用的 HTTP GET URL,并希望将其替换为 SOAP

HTTP GET

GET /WsServices/WsServices.asmx/PagoFactura?AppUsuario=string&AppPassword=string&Usuario=string&Password=string&monto=string&cantidadFacturas=string&IdEmpresaServicio=string&IdUsuarioEmpresaServicio=string&IdCuenta=string&cvv=String&xmlFacturas=string HTTP/1.1
Host: 200.26.174.211
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

至此

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>

这是示例中的 Android 代码。我很困惑如何将上述内容放入 android 代码中。请帮助我了解 XMLNS 和方法名称

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

最佳答案

这是一个关于使用 k-soap 处理 Web 服务的精彩视频教程:

Example

关于java - Android中SOAP的HTTP GET方法,请纠正我,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7111650/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com