android中的KSOAP异常

时间:2012-05-10 04:25:27

标签: android ksoap2

我在我的应用程序中使用KSOAP来调用一个webservices.In我得到一些异常。我使用以下代码:

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            envelope.setOutputSoapObject(request);
            envelope.dotNet=true;           
            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);  
            try
            {
                androidHttpTransport.call(SOAP_ACTION, envelope);              
//              SoapPrimitive response = (SoapPrimitive)envelope.getResponse();    
                SoapObject response=(SoapObject)envelope.getResponse();      ------>getting exceptopn here
}  

我收到以下错误:

 W/System.err(994): SoapFault - faultcode: 'soap:Server' faultstring: 'System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.NullReferenceException: Object reference not set to an instance of an object.

 W/System.err(994):    --- End of inner exception stack trace ---' faultactor: 'null' detail: org.kxml2.kdom.Node@44ed4ff0
 W/System.err(994):     at org.ksoap2.serialization.SoapSerializationEnvelope.parseBody(SoapSerializationEnvelope.java:116)
 W/System.err(994):     at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:137)
 W/System.err(994):     at org.ksoap2.transport.Transport.parseResponse(Transport.java:63)
 W/System.err(994):     at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:100)
 W/System.err(994):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
 W/System.err(994):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
 W/System.err(994):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
 W/System.err(994):     at android.app.ActivityThread.access$2200(ActivityThread.java:119)
 W/System.err(994):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
 W/System.err(994):     at android.os.Handler.dispatchMessage(Handler.java:99)
 W/System.err(994):     at android.os.Looper.loop(Looper.java:123)
 W/System.err(994):     at android.app.ActivityThread.main(ActivityThread.java:4363)
 W/System.err(994):     at java.lang.reflect.Method.invokeNative(Native Method)
 W/System.err(994):     at java.lang.reflect.Method.invoke(Method.java:521)
 W/System.err(994):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
 W/System.err(994):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
 W/System.err(994):     at dalvik.system.NativeStart.main(Native Method)
 I/ActivityManager(60): Displayed activity com.redbus/.SearchRoute: 2501 ms (total 2501 ms)

任何人都可以帮助我..

1 个答案:

答案 0 :(得分:0)

你可以找出你的问题,这里是正在运行的代码::

            SoapObject request = new SoapObject(NAMESPACE,METHODE_NAME);
            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
                    SoapEnvelope.VER11);
            request.addProperty("image", param[0]);
            request.addProperty("desc", param[1]);
            request.addProperty("venueId", param[2]);
            request.addProperty("userId", param[3]);
            envelope.setOutputSoapObject(request);
            envelope.dotNet = true;
            HttpTransportSE androidHttpTransport = new HttpTransportSE(
                    Data.URL_BASE, 20000);
            try {
                androidHttpTransport.call(Data.SOAP_ACTION, envelope);
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                responseXML = null;
            }
            SoapObject resultsRequestSOAP = (SoapObject) envelope.bodyIn;
            String responseLocal = resultsRequestSOAP.toString();

让我知道你是否还有问题,