gpt4 book ai didi

Android KSOAP2 ServiceConnectionSE NullPointerException

转载 作者:行者123 更新时间:2023-11-29 02:00:51 24 4
gpt4 key购买 nike

我尝试在我的 android 应用程序中实现 KSOAP2,但现在我遇到了问题。当我使用 HTTPTransportSE 对象的调用方法时,我收到以下异常:

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)

这是我的代码:

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

我希望你能帮助我..我已经尝试修复这个错误好几天了

最佳答案

我解决了这个问题。不幸的是,HTTPConnection 存在问题,如果没有 ksoap2 源,则很难找到它。我检查了代码,发现 ksoap2 使用 Java 中的普通 URL 和 HTTPConnection。我构建了一个简单的示例来连接到我的 URL,但发现无法连接。

注意:在你开始思考复杂的事情之前先检查简单的事情:)

关于Android KSOAP2 ServiceConnectionSE NullPointerException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12723517/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com