English 中文(简体)
KSOAP 无效例外[重复]
原标题:KSOAP null pointer exception [duplicate]
This question already has an answer here:
Closed 11 years ago.

Possible Duplicate:
Cannot serialize issue in KSOAP in android

在我的申请中,我使用了SOAP服务,因为我的SOAP要求结构是

<authentication>
        <LoginID>string</LoginID>
        <Password>string</Password>
      </authentication>
      <ID>int</ID>
      <ID>int</ID>
      <dojStr>string</dojStr>
      <Data>
        <Keys>
          <POfStringString>
            <V>string</V>
            <K>string</K>
          </POfStringString>
          <POfStringString>
            <V>string</V>
            <K>string</K>
          </POfStringString>
        </Keys>
        <CriteriaKeys>
          <POfStringString>
            <V>string</V>
            <K>string</K>
          </POfStringString>
          <POfStringString>
            <V>string</V>
            <K>string</K>
          </POfStringString>
        </CriteriaKeys>
        <No>int</No>
        <Size>int</Size>
      </Data>    
  </soap:Body>
</soap:Envelope>

我的法典如下:

 SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);           
            SoapObject authentication = new SoapObject(NAMESPACE,"authentication"); 
            SoapObject pagination = new SoapObject(NAMESPACE,"pagination"); 

                 authentication.addProperty(usrid); 
                 authentication.addProperty(pass);  

            request.addSoapObject(authentication); 

                request.addProperty(Id);   
                request.addProperty(Id);  
                request.addProperty(dte);

                PropertyInfo page =new PropertyInfo();    
                page.setName("V");  
//          page.setName("K");   
            page.setValue("10");
            page.setType(String.class);
            pagination.addProperty(page);

                request.addSoapObject(pagination);


                request.addProperty(no);
                request.addProperty(size);    

              SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            envelope.setOutputSoapObject(request);
//          envelope.addMapping(NAMESPACE, "authentication", new Array().getClass());
            envelope.dotNet=true;           
            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);    
            try
            {         
                androidHttpTransport.call(SOAP_ACTION,envelope);               
//              SoapPrimitive response = (SoapPrimitive)envelope.getResponse();            
                Object result=(Object)envelope.getResponse(); ----->Getting error here.

越狱:

    java.lang.NullPointerException
at java.io.Writer.write(Writer.java:152)
at org.kxml2.io.KXmlSerializer.startTag(KXmlSerializer.java:407)
at org.ksoap2.serialization.SoapSerializationEnvelope.writeObjectBody(SoapSerializationEnvelope.java:660)
at org.ksoap2.serialization.SoapSerializationEnvelope.writeObjectBody(SoapSerializationEnvelope.java:645)
at org.ksoap2.serialization.SoapSerializationEnvelope.writeObjectBody(SoapSerializationEnvelope.java:642)
at org.ksoap2.serialization.SoapSerializationEnvelope.writeElement(SoapSerializationEnvelope.java:702)
at org.ksoap2.serialization.SoapSerializationEnvelope.writeBody(SoapSerializationEnvelope.java:618)


at org.ksoap2.SoapEnvelope.write(SoapEnvelope.java:198)
    at org.ksoap2.transport.Transport.createRequestData(Transport.java:111)
    at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:119)
    at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:95)
    at com.redbus.SearchRoute.onCreate(SearchRoute.java:151)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
    at android.app.ActivityThread.access$2200(ActivityThread.java:119)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:123)
    at android.app.ActivityThread.main(ActivityThread.java:4363)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:521)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
    at dalvik.system.NativeStart.main(Native Method)

是否正确地确定投入,或者说什么是错误的。 提前感谢。

问题回答

使用肥皂排放结果=(SoapPrimitive)envelope.getResponse();结果。

这将发挥作用。 如果我在此不作答复,我会再给你一个办法。





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签