ksoap2和Android总是返回空指针异常
我尝试使用 SOAP Web 服务失败(我不知道该 WS 背后的架构是什么,因为它是外部服务)。
我的代码是:
try{
_FakeX509TrustManager.allowAllSSL();
_FakeX509TrustManager trustM = new _FakeX509TrustManager();
trustM.isServerTrusted(null);
InetAddress address = InetAddress.getByName("mirservicetest.sanita.finanze.it");
Log.i(IMEDCERTIFICATI,address.toString());
androidTransport.call(SOAP_ACTION, envelope,headerPropertyList);
//androidTransport.call(SOAP_ACTION, envelope,headerPropertyList);
SoapObject response=(SoapObject)envelope.getResponse();
Log.i(IMEDCERTIFICATI,"Ho ricevuto qualcosa dal ws");
Log.i(IMEDCERTIFICATI,response.toString());
//response.getProperty(0);
}catch(Exception ex){
ex.printStackTrace();
}
我必须允许所有 ssl 证书,因为这是一个测试环境。 堆栈跟踪如下:
01-16 19:18:39.117: D/imedcertificati(14282): Full SSL active on new operating system version 15
01-16 19:18:39.128: W/System.err(14282): java.lang.NullPointerException
01-16 19:18:39.156: W/System.err(14282): at libcore.net.http.HttpConnection$Address.hashCode(HttpConnection.java:343)
01-16 19:18:39.156: W/System.err(14282): at java.util.HashMap.get(HashMap.java:298)
01-16 19:18:39.156: W/System.err(14282): at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:67)
01-16 19:18:39.160: W/System.err(14282): at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
01-16 19:18:39.160: W/System.err(14282): at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:308)
01-16 19:18:39.160: W/System.err(14282): at libcore.net.http.HttpsURLConnectionImpl$HttpsEngine.makeSslConnection(HttpsURLConnectionImpl.java:460)
01-16 19:18:39.160: W/System.err(14282): at libcore.net.http.HttpsURLConnectionImpl$HttpsEngine.connect(HttpsURLConnectionImpl.java:432)
01-16 19:18:39.160: W/System.err(14282): at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:282)
01-16 19:18:39.160: W/System.err(14282): at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:232)
01-16 19:18:39.160: W/System.err(14282): at libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:80)
01-16 19:18:39.160: W/System.err(14282): at libcore.net.http.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:164)
01-16 19:18:39.160: W/System.err(14282): at it.senetech.iMedCertificati.utils.AndroidInsecureHttpsServiceConnectionSE.connect(AndroidInsecureHttpsServiceConnectionSE.java:117)
01-16 19:18:39.160: W/System.err(14282): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:152)
01-16 19:18:39.164: W/System.err(14282): at it.senetech.iMedCertificati.SendCertificato.onClick(SendCertificato.java:169)
01-16 19:18:39.164: W/System.err(14282): at android.view.View.performClick(View.java:3511)
01-16 19:18:39.164: W/System.err(14282): at android.view.View$PerformClick.run(View.java:14105)
01-16 19:18:39.164: W/System.err(14282): at android.os.Handler.handleCallback(Handler.java:605)
01-16 19:18:39.164: W/System.err(14282): at android.os.Handler.dispatchMessage(Handler.java:92)
01-16 19:18:39.164: W/System.err(14282): at android.os.Looper.loop(Looper.java:137)
01-16 19:18:39.168: W/System.err(14282): at android.app.ActivityThread.main(ActivityThread.java:4424)
01-16 19:18:39.168: W/System.err(14282): at java.lang.reflect.Method.invokeNative(Native Method)
01-16 19:18:39.168: W/System.err(14282): at java.lang.reflect.Method.invoke(Method.java:511)
01-16 19:18:39.168: W/System.err(14282): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
01-16 19:18:39.168: W/System.err(14282): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
01-16 19:18:39.168: W/System.err(14282): at dalvik.system.NativeStart.main(Native Method)
01-16 19:20:09.164: W/IInputConnectionWrapper(14282): showStatusIcon on inactive InputConnection
我试图使其尽可能可读。
预先感谢您的帮助,并对我糟糕的英语表示歉意。
I'm unsuccessfully trying to consume a SOAP webservice (I can't know which architecture is behind this WS, as it is an external service).
My code is :
try{
_FakeX509TrustManager.allowAllSSL();
_FakeX509TrustManager trustM = new _FakeX509TrustManager();
trustM.isServerTrusted(null);
InetAddress address = InetAddress.getByName("mirservicetest.sanita.finanze.it");
Log.i(IMEDCERTIFICATI,address.toString());
androidTransport.call(SOAP_ACTION, envelope,headerPropertyList);
//androidTransport.call(SOAP_ACTION, envelope,headerPropertyList);
SoapObject response=(SoapObject)envelope.getResponse();
Log.i(IMEDCERTIFICATI,"Ho ricevuto qualcosa dal ws");
Log.i(IMEDCERTIFICATI,response.toString());
//response.getProperty(0);
}catch(Exception ex){
ex.printStackTrace();
}
I had to allow all ssl certificate because this is a testing environment.
The stack trace is the following:
01-16 19:18:39.117: D/imedcertificati(14282): Full SSL active on new operating system version 15
01-16 19:18:39.128: W/System.err(14282): java.lang.NullPointerException
01-16 19:18:39.156: W/System.err(14282): at libcore.net.http.HttpConnection$Address.hashCode(HttpConnection.java:343)
01-16 19:18:39.156: W/System.err(14282): at java.util.HashMap.get(HashMap.java:298)
01-16 19:18:39.156: W/System.err(14282): at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:67)
01-16 19:18:39.160: W/System.err(14282): at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
01-16 19:18:39.160: W/System.err(14282): at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:308)
01-16 19:18:39.160: W/System.err(14282): at libcore.net.http.HttpsURLConnectionImpl$HttpsEngine.makeSslConnection(HttpsURLConnectionImpl.java:460)
01-16 19:18:39.160: W/System.err(14282): at libcore.net.http.HttpsURLConnectionImpl$HttpsEngine.connect(HttpsURLConnectionImpl.java:432)
01-16 19:18:39.160: W/System.err(14282): at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:282)
01-16 19:18:39.160: W/System.err(14282): at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:232)
01-16 19:18:39.160: W/System.err(14282): at libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:80)
01-16 19:18:39.160: W/System.err(14282): at libcore.net.http.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:164)
01-16 19:18:39.160: W/System.err(14282): at it.senetech.iMedCertificati.utils.AndroidInsecureHttpsServiceConnectionSE.connect(AndroidInsecureHttpsServiceConnectionSE.java:117)
01-16 19:18:39.160: W/System.err(14282): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:152)
01-16 19:18:39.164: W/System.err(14282): at it.senetech.iMedCertificati.SendCertificato.onClick(SendCertificato.java:169)
01-16 19:18:39.164: W/System.err(14282): at android.view.View.performClick(View.java:3511)
01-16 19:18:39.164: W/System.err(14282): at android.view.View$PerformClick.run(View.java:14105)
01-16 19:18:39.164: W/System.err(14282): at android.os.Handler.handleCallback(Handler.java:605)
01-16 19:18:39.164: W/System.err(14282): at android.os.Handler.dispatchMessage(Handler.java:92)
01-16 19:18:39.164: W/System.err(14282): at android.os.Looper.loop(Looper.java:137)
01-16 19:18:39.168: W/System.err(14282): at android.app.ActivityThread.main(ActivityThread.java:4424)
01-16 19:18:39.168: W/System.err(14282): at java.lang.reflect.Method.invokeNative(Native Method)
01-16 19:18:39.168: W/System.err(14282): at java.lang.reflect.Method.invoke(Method.java:511)
01-16 19:18:39.168: W/System.err(14282): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
01-16 19:18:39.168: W/System.err(14282): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
01-16 19:18:39.168: W/System.err(14282): at dalvik.system.NativeStart.main(Native Method)
01-16 19:20:09.164: W/IInputConnectionWrapper(14282): showStatusIcon on inactive InputConnection
I tried to make it as readable as possible.
Thanks in advance for the help and sorry for my poor english.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,这是由错误的信封构造函数引起的。
Ok, this was caused by a wrong envelope constructor.