我测试了用 ksoap2 调用一个soap 12 webservices。我用这段代码来调用网络服务:
SoapObject request = new SoapObject(NAMESPACE, NAME);
request.addProperty("id", ID);
request.addProperty("name", "test@test.de");
request.addProperty("pw", "password");
request.addProperty("listid", 501);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER12);
envelope.setOutputSoapObject(request);
AndroidHttpTransport client = new AndroidHttpTransport(URL);
try {
client.call(NAMESPACE + NAME, envelope);
Object response = envelope.getResponse();
} catch (IOException e) {
Log.e(getClass().getSimpleName(), "IO Problem", e);
} catch (XmlPullParserException e) {
Log.e(getClass().getSimpleName(), "Parser Problem", e);
}
我现在得到以下异常:
org.xmlpull.v1.XmlPullParserException:expected: START_TAG {http://www.w3.org/2001/12/soap-envelope}Envelope (position:START_TAG <{http://schemas.xmlsoap.org/soap/envelope/}soapenv:Envelope>@1:114 in java.io.InputStreamReader@44f28a80)
这是服务器响应的问题,还是到目前为止我的代码有问题?似乎其他用户也有同样的问题。如果我将信封更改为 SoapEnvelope.VER11,我会更进一步(我收到来自肥皂服务器的拒绝访问响应可能是因为 URL 错误)可能缺少创建 VER12 信封的其他信息。