Android KSOAP2 ServiceConnectionSE NullPointerException

浪子不回头ぞ 提交于 2019-12-06 09:35:03

问题


I try to implement KSOAP2 in my android application and now im having a problem. When i use the call method of the HTTPTransportSE Object im getting the following exception:

10-04 09:24:05.997: W/System.err(6779): java.lang.NullPointerException
10-04 09:24:06.017: W/System.err(6779):     at org.ksoap2.transport.ServiceConnectionSE.getResponseProperties(ServiceConnectionSE.java:85)
10-04 09:24:06.017: W/System.err(6779):     at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:167)
10-04 09:24:06.017: W/System.err(6779):     at com.brandmakerandroid.mediapool.LoginActivity.Login(LoginActivity.java:123)
10-04 09:24:06.017: W/System.err(6779):     at java.lang.reflect.Method.invokeNative(Native Method)
10-04 09:24:06.017: W/System.err(6779):     at java.lang.reflect.Method.invoke(Method.java:511)
10-04 09:24:06.017: W/System.err(6779):     at android.view.View$1.onClick(View.java:3077)
10-04 09:24:06.017: W/System.err(6779):     at android.view.View.performClick(View.java:3549)
10-04 09:24:06.017: W/System.err(6779):     at android.view.View$PerformClick.run(View.java:14400)
10-04 09:24:06.017: W/System.err(6779):     at android.os.Handler.handleCallback(Handler.java:605)
10-04 09:24:06.017: W/System.err(6779):     at android.os.Handler.dispatchMessage(Handler.java:92)
10-04 09:24:06.017: W/System.err(6779):     at android.os.Looper.loop(Looper.java:154)
10-04 09:24:06.017: W/System.err(6779):     at android.app.ActivityThread.main(ActivityThread.java:4945)
10-04 09:24:06.017: W/System.err(6779):     at java.lang.reflect.Method.invokeNative(Native Method)
10-04 09:24:06.017: W/System.err(6779):     at java.lang.reflect.Method.invoke(Method.java:511)
10-04 09:24:06.017: W/System.err(6779):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
10-04 09:24:06.017: W/System.err(6779):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
10-04 09:24:06.017: W/System.err(6779):     at dalvik.system.NativeStart.main(Native Method)

And here is my Code:

            SoapObject request= new SoapObject(Constants.NAMESPACE, Constants.METHOD_NAME);

            SoapObject mda = new SoapObject("","arg0");

            PropertyInfo pi = new PropertyInfo();
            pi.setName("mediaGuid");
            pi.setValue("27499");
            pi.setType(String.class);
            mda.addProperty(pi);

            PropertyInfo pi_hash = new PropertyInfo();
            pi_hash.setName("mediaHash");
            pi_hash.setValue("");
            pi_hash.setType(String.class);

            mda.addProperty(pi_hash);

            request.addSoapObject(mda);

            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
                    SoapEnvelope.VER11);
            envelope.setOutputSoapObject(request);
            envelope.addMapping(Constants.NAMESPACE, "getMediaDetails", getMediaDetails.class);

            try {
                HttpTransportSE httpTransportSE = new HttpTransportSE(Constants.DEFAULT_SERVER);
                httpTransportSE.debug = true;

                List<HeaderProperty> headerList = new ArrayList<HeaderProperty>();
                headerList.add(new HeaderProperty("Authorization", "Basic "
                        + org.kobjects.base64.Base64.encode("xxxxxxxx"
                                .getBytes())));

                httpTransportSE.call(Constants.SOAP_ACTION, envelope, headerList);

                SoapObject objectResult = (SoapObject) envelope.getResponse();

I hope u can help me .. im tryin to fix that error for days


回答1:


I solved the problem. There was a problem with the HTTPConnection unfortunatley it is not so easy to find it without the ksoap2 sources. I checked out the code and found out that ksoap2 use the normal URL and HTTPConnection from Java. I built a simple example to connect to my URL and noticed that it was not possible to connect.

Notice: first check the simple things before you start to think to complex :)



来源:https://stackoverflow.com/questions/12723517/android-ksoap2-serviceconnectionse-nullpointerexception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!