Android的KSOAP2 ServiceConnectionSE NullPointerException异常 [英] Android KSOAP2 ServiceConnectionSE NullPointerException

查看:280
本文介绍了Android的KSOAP2 ServiceConnectionSE NullPointerException异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试实施KSOAP2在我的Andr​​oid应用程序,现在即时通讯有问题。当我使用HTTPTransportSE对象IM的调用方法得到以下异常:

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)

和这里是我的code:

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();

我希望u能帮助我..即时通讯试着解决这个错误天

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

推荐答案

我解决了这个问题。有一个与一个的HttpConnection问题unfortunatley也不是那么容易找到它没有ksoap2源。我检查了code和发现,ksoap2使用正常的URL和HttpConnection的从Java。我建立了一个简单的例子来连接到我的网址,发现它无法连接。

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 :)

这篇关于Android的KSOAP2 ServiceConnectionSE NullPointerException异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆