我在 Android 中访问复杂的 WCF Web 服务时遇到问题。关于我的问题的详细信息如下:
对 WCF Web 服务的典型请求具有以下 XML:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header><Action s:mustUnderstand="1"xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://tempuri.org/manojService/MethodName</Action>
</s:Header>
<s:Body>
<MethodName xmlns="http://tempuri.org/">
<name>ABC</name>
<Collection xmlns:d4p1="http://schemas.datacontract.org/2004/07/YXZ.Model" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<d4p1:location>whatever</d4p1:location>
<d4p1:OfficeLocation>
<d4p1:Lattitude>28.5</d4p1:Lattitude>
<d4p1:LocationID>0</d4p1:LocationID>
</d4p1:OfficeLocation>
</Collection>
<Action>Add</Action>
</MethodName>
</s:Body>
</s:Envelope>
我正在使用简单的 SOAP 概念使用 KSoap 库进行登录,如下所示:
try {
StringBuilder sb = null;
SoapObject request = new SoapObject("http://tempuri.org/",
"methodName");
request.addProperty("name", "aaaa");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE( "Service urls");
androidHttpTransport.call("http://tempuri.org/manojService/MethodName", envelope);
Object result = (Object) envelope.getResponse();
String resultData = result.toString();
System.out.println("result Data :-" + resultData);
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
System.out.println("error is occured :-" + e.getMessage());
}
如果您有任何在soap中发送数组类型数据的解决方案,请告诉我。