ksoap2 android 1c 不同xml 结构
ksoap2 android 1c different xml structure
ksoap2 像这样生成 xml
<?xml
version="1.0"
encoding="UTF-8"
?>
<env:Envelope>
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<env:Body>
<tns:GetListClient>
xmlns:tns="http://www.spr.org"
hello
</tns:GetListClient>
</env:Body>
</env:Envelope>
但是 web-service 1c,只排除这样的 xml-结构化文件
<soap:Envelope>
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
<soap:Header/>
<soap:Body>
<m:GetListClient>
xmlns:m="http://www.spr.org"
<m:Param/>
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
</m:GetListClient>
</soap:Body>
</soap:Envelope>
如您所见,不同之处在于此参数
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Android代码
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("Celsius", "23");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.implicitTypes = true;
envelope.setOutputSoapObject(request);
Log.e("request", request.toString());
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.debug = true;
try {
androidHttpTransport.call(SOAP_ACTION, envelope,headerProperty);
SoapPrimitive response = (SoapPrimitive) envelope.getResponse();
resultString = response.toString();
Log.e("requestDumpCelsius",androidHttpTransport.requestDump);
Log.e("responseDumpCelsius",androidHttpTransport.responseDump);
} catch (Exception e) {
e.printStackTrace();
resultString = null;
}
if(resultString!=null)
return resultString;
}
它给了我这样的例外
03-04 12:17:53.723 3932-3945/eu.msdlab.postmobile W/System.err﹕ SoapFault - faultcode: 'soap:Client' faultstring: 'Ошибка разбора SOAP сообщения: неизвестный параметр. ' faultactor: 'null' detail: org.kxml2.kdom.Node@41bf3470
03-04 12:17:53.723 3932-3945/eu.msdlab.postmobile W/System.err﹕ at org.ksoap2.serialization.SoapSerializationEnvelope.parseBody(SoapSerializationEnvelope.java:137)
03-04 12:17:53.723 3932-3945/eu.msdlab.postmobile W/System.err﹕ at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:140)
03-04 12:17:53.723 3932-3945/eu.msdlab.postmobile W/System.err﹕ at org.ksoap2.transport.Transport.parseResponse(Transport.java:129)
我需要的是更改 xml 文件的结构
但是 PropertyInfo 只允许我添加一个命名空间
问题解决
好像我使用了错误的属性
据我了解你的代码,这可能是NAMESPACE
问题
尝试使用
private static String NAMESPACE = "http://tempuri.org/";
如果上面的方法不起作用那么
private static String NAMESPACE = "xmlns:m="http://www.spr.org"";
如果以上两者都不适合您,那么请 post WSDL
ksoap2 像这样生成 xml
<?xml
version="1.0"
encoding="UTF-8"
?>
<env:Envelope>
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<env:Body>
<tns:GetListClient>
xmlns:tns="http://www.spr.org"
hello
</tns:GetListClient>
</env:Body>
</env:Envelope>
但是 web-service 1c,只排除这样的 xml-结构化文件
<soap:Envelope>
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
<soap:Header/>
<soap:Body>
<m:GetListClient>
xmlns:m="http://www.spr.org"
<m:Param/>
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
</m:GetListClient>
</soap:Body>
</soap:Envelope>
如您所见,不同之处在于此参数
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Android代码
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("Celsius", "23");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.implicitTypes = true;
envelope.setOutputSoapObject(request);
Log.e("request", request.toString());
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.debug = true;
try {
androidHttpTransport.call(SOAP_ACTION, envelope,headerProperty);
SoapPrimitive response = (SoapPrimitive) envelope.getResponse();
resultString = response.toString();
Log.e("requestDumpCelsius",androidHttpTransport.requestDump);
Log.e("responseDumpCelsius",androidHttpTransport.responseDump);
} catch (Exception e) {
e.printStackTrace();
resultString = null;
}
if(resultString!=null)
return resultString;
}
它给了我这样的例外
03-04 12:17:53.723 3932-3945/eu.msdlab.postmobile W/System.err﹕ SoapFault - faultcode: 'soap:Client' faultstring: 'Ошибка разбора SOAP сообщения: неизвестный параметр. ' faultactor: 'null' detail: org.kxml2.kdom.Node@41bf3470
03-04 12:17:53.723 3932-3945/eu.msdlab.postmobile W/System.err﹕ at org.ksoap2.serialization.SoapSerializationEnvelope.parseBody(SoapSerializationEnvelope.java:137)
03-04 12:17:53.723 3932-3945/eu.msdlab.postmobile W/System.err﹕ at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:140)
03-04 12:17:53.723 3932-3945/eu.msdlab.postmobile W/System.err﹕ at org.ksoap2.transport.Transport.parseResponse(Transport.java:129)
我需要的是更改 xml 文件的结构 但是 PropertyInfo 只允许我添加一个命名空间
问题解决 好像我使用了错误的属性
据我了解你的代码,这可能是NAMESPACE
问题
尝试使用
private static String NAMESPACE = "http://tempuri.org/";
如果上面的方法不起作用那么
private static String NAMESPACE = "xmlns:m="http://www.spr.org"";
如果以上两者都不适合您,那么请 post WSDL