android - ksoap2和soap版本12有问题吗?

标签 android soap ksoap2

我测试了使用kso​​ap2调用soap 12 webservices。 我使用此代码来调用网络服务:

SoapObject request = new SoapObject(NAMESPACE, NAME);
request.addProperty("id", ID);
request.addProperty("name", "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="483c2d3b3c083c2d3b3c662c2d" rel="noreferrer noopener nofollow">[email protected]</a>");
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 错误而从 SOAP 服务器收到访问被拒绝的响应),可能缺少创建 VER12 信封的附加信息。

最佳答案

您是否尝试过信封的各种选项以了解服务的期望?

例如你可以设置

envelope.dotNet = true;
envelope.headerOut = security; // this is an Element[] created before
envelope.encodingStyle = SoapEnvelope.ENC;
envelope.setAddAdornments(false);
envelope.implicitTypes = false;

还有更多。查看javadoc?

还要确保使用最新版本的 ksoap2-android 项目来获取正常 sourceforge 项目中没有的一系列修复程序。

关于android - ksoap2和soap版本12有问题吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4189081/

相关文章:

android - 如何在没有可写和可执行段的情况下为Android O编译.so?如何设置特定的ELF权限?

android - 根据哪个 Activity 包含 fragment 执行 Intent

xml - 公共(public) SOAP WSDL 文件是否存在安全问题?

java - ksoap2 将 String[] 设置为 request.addProperty

android - ksoap2 Android 意外类型响应

java - 无法从 SOAP 响应中获取值

c# - Realm Xamarin - GetInstance() 错误

android - React-native list 合并失败

java - 如何在 Hibernate Java obj 中添加 @XmlTransient

soap - SOAP 现在是遗留技术吗?