Tuesday, April 16, 2013

[android help] xmlpullparser exception while trying to consume a method

android - xmlpullparser exception while trying to consume a method - Stack Overflow







Tell me more ×

Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

















i am trying to consume webservice method using ksaop2.


here is the code



try {

SOAP_ACTION = NAMESPACE + METHOD;

SoapObject request = new SoapObject(NAMESPACE, METHOD);

SoapSerializationEnvelope res = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
res.dotNet = true;
res.setOutputSoapObject(request);

HttpTransportSE call = new HttpTransportSE(url);

SoapPrimitive result;
call.call(SOAP_ACTION, res);
result = (SoapPrimitive) res.getResponse();

ParseLocations Objparsecities = new ParseLocations(
new ByteArrayInputStream(result.toString()
.getBytes("UTF-8")));
lstresponse = Objparsecities.parse();

System.out.println(lstresponse);

} catch (SoapFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (XmlPullParserException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}


it works fine on emulator but when i try to run on my device i am getting the following error



04-16 15:54:11.761: W/System.err(3982): org.xmlpull.v1.XmlPullParserException: unexpected type (position:END_DOCUMENT null@1:0 in java.io.InputStreamReader@405f2fe8)
04-16 15:54:11.761: W/System.err(3982): at org.kxml2.io.KXmlParser.exception(KXmlParser.java:273)
04-16 15:54:11.761: W/System.err(3982): at org.kxml2.io.KXmlParser.nextTag(KXmlParser.java:1413)
04-16 15:54:11.761: W/System.err(3982): at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:126)
04-16 15:54:11.761: W/System.err(3982): at org.ksoap2.transport.Transport.parseResponse(Transport.java:63)
04-16 15:54:11.761: W/System.err(3982): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:100)
04-16 15:54:11.761: W/System.err(3982): at com.netserv.Pungry.LocationbyCities.SendRequesttoServer(LocationbyCities.java:249)
04-16 15:54:11.761: W/System.err(3982): at com.netserv.Pungry.LocationbyCities$CityData.doInBackground(LocationbyCities.java:216)
04-16 15:54:11.761: W/System.err(3982): at com.netserv.Pungry.LocationbyCities$CityData.doInBackground(LocationbyCities.java:1)
04-16 15:54:11.761: W/System.err(3982): at android.os.AsyncTask$2.call(AsyncTask.java:185)
04-16 15:54:11.761: W/System.err(3982): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
04-16 15:54:11.761: W/System.err(3982): at java.util.concurrent.FutureTask.run(FutureTask.java:138)
04-16 15:54:11.761: W/System.err(3982): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
04-16 15:54:11.761: W/System.err(3982): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
04-16 15:54:11.761: W/System.err(3982): at java.lang.Thread.run(Thread.java:1027)
04-16 15:54:11.771: W/System.err(3982): java.lang.NullPointerException
04-16 15:54:11.771: W/System.err(3982): at com.netserv.Pungry.LocationbyCities$CityData.onPostExecute(LocationbyCities.java:202)
04-16 15:54:11.771: W/System.err(3982): at com.netserv.Pungry.LocationbyCities$CityData.onPostExecute(LocationbyCities.java:1)
04-16 15:54:11.771: W/System.err(3982): at android.os.AsyncTask.finish(AsyncTask.java:417)
04-16 15:54:11.771: W/System.err(3982): at android.os.AsyncTask.access$300(AsyncTask.java:127)
04-16 15:54:11.771: W/System.err(3982): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429)
04-16 15:54:11.771: W/System.err(3982): at android.os.Handler.dispatchMessage(Handler.java:99)
04-16 15:54:11.771: W/System.err(3982): at android.os.Looper.loop(Looper.java:150)
04-16 15:54:11.771: W/System.err(3982): at android.app.ActivityThread.main(ActivityThread.java:4263)
04-16 15:54:11.771: W/System.err(3982): at java.lang.reflect.Method.invokeNative(Native Method)
04-16 15:54:11.771: W/System.err(3982): at java.lang.reflect.Method.invoke(Method.java:507)
04-16 15:54:11.771: W/System.err(3982): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-16 15:54:11.771: W/System.err(3982): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-16 15:54:11.781: W/System.err(3982): at dalvik.system.NativeStart.main(Native Method)


Can i know what is the mistake?


Thanks:)
















Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.










default






.

stackoverflow.comm

No comments:

Post a Comment

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...