ksoap2和Android总是返回空指针异常

发布于 2024-12-27 02:44:36 字数 4113 浏览 1 评论 0原文

我尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

内心激荡 2025-01-03 02:44:36

好的,这是由错误的信封构造函数引起的。

Ok, this was caused by a wrong envelope constructor.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文