tags:

views:

559

answers:

2

Hi all, I am developing an application which uses KSOAP2 with Android 2.0. But I am getting error "org.xmlpull.v1.XmlPullParserException: expected: START_TAG" can anyone tell me why this is happening?? Regards, Pankaj Deshpande

+1  A: 

It's hard to say but the Exception might be due to malformed XML being passed to the Parser. It's possible that you're not initialising parser correctly and so it can't see any XML.

Can you edit your question add the code you have which uses the Parser.

Dave Webb
A: 

Hello, When I use SoapEnvelope.VER11, it works fine, But when I use SoapEnvelope.VER12, it gives me error: "org.xmlpull.v1.XmlPullParserException: expected: START_TAG". This is my code...

import java.io.IOException;

import org.ksoap2.SoapEnvelope; import org.ksoap2.serialization.SoapObject; import org.ksoap2.serialization.SoapSerializationEnvelope;

import org.ksoap2.transport.HttpTransportSE; import org.xmlpull.v1.XmlPullParserException;

import android.os.Bundle; import android.util.Log; import android.widget.TextView;

public class MyWebService extends Activity { private static final String SOAP_ACTION = "http://your_URL/ your_mathod_name"; private static final String METHOD_NAME = "your_mathod_name"; private static final String NAMESPACE = "http://your_URL/"; private static final String URL = "http://your_URL/WebService.asmx? WSDL"; private Object resultRequestSOAP = null; String data = "some data";

   /** Called when the activity is first created. */
   @Override
   public void onCreate(Bundle savedInstanceState) {
           super.onCreate(savedInstanceState);
           TextView tv = new TextView(this);
           setContentView(tv);
           try {

                   SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
                   SoapSerializationEnvelope envelope = new

SoapSerializationEnvelope(SoapEnvelope.VER12); envelope.encodingStyle = SoapSerializationEnvelope.ENC2001; envelope.dotNet = true; envelope.setOutputSoapObject(request); request.addProperty(METHOD_NAME, data); envelope.bodyOut = request; SoapObject response = null; HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); androidHttpTransport.call(SOAP_ACTION, envelope); // get the data response = (SoapObject) envelope.bodyIn;

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

                   e.printStackTrace();
           }

   }

}

Can u tell me why is this happening with SOAP1.2 ? Do I need to specify some encoding style for SOAP1.2 ?

Pankaj Deshpande