Ksoap2 Org.Xmlpull.V1.Xmlpullparserexception Expected Start_Tag Error

ksoap2 org.xmlpull.v1.xmlpullparserexception expected start_tag error

The answer to this question as I figure it out is, in the SOAP_ADDRESS string, remove the /WebSiteName part and it works fine. I have tested this in my android device. Works perfectly.

The corrected String should be as follow:

private static final String SOAP_ADDRESS = "http://myStaticIP:portNo/CommunicationInterface.asmx";

where CommunicationInterface.asmx is the web service name.
other static variables remain same.

Note: This is used when the web site is hosted in IIS.

org.xmlpull.v1.xmlpullparserexception expected start_tag error when using ksoap2

There might be a few reasons for the exception that you are getting.

  1. Wrong Parameters for the SOAP call : try to confirm if the values of NAMESPACE, ACTION, METHOD and URL are correct or not, by looking at the WSDL file
  2. Invalid response from server : try to log the response that the server sends to you and check if you are getting correct well-structured XML or not

    androidHttpTransport.debug = true;

    //execute request

    androidHttpTransport.responseDump; //response string from server

  3. dotNet attribute of the envelope : try using soapEnvelope.dotNet=true

kSOAP2 output / org.xmlpull.v1.xmlpullparserexception expected start_tag

Well now that I've solved my original problem hit this one!

I found that ksoap2 couldn't parse the response... specifically org.kxml2.io.KXmlParser.require(type, namespace, name) threw the following exception.

WARN/System.err(2330): org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://www.w3.org/2001/12/soap-envelope}Envelope (position:START_TAG <h1>@1:4 in java.io.InputStreamReader@47ff3050) 

Note that h1 tag. That comes from <h1>404 Not Found</h1> ... so yes, be aware your response may be from a website but not your web service :)

Hope that helps someone one day

XmlPullParserException: expected: START_TAG ...definitions

The XMLParserException could get thrown at two points.

  1. When the Library tries to generate the SoapObject before the call
  2. After the call, when the response object is not a valid XML(for example you could get

    a HTML response with a server error)

Debug your Webservice call and check the dump variables of your HTTPTransportSE Object to find out if your XML is valid. You also can copy paste the content of the dump variables into soapUI to check which of your xml parts are not working.

This helped me alot http://mspmsp.brinkster.net/MobileJava/ch16.htm

I hope it helps.



Related Topics



Leave a reply



Submit