“org.xmlpull.v1.XmlPullParserException: expected: START_TAG” Error

余生长醉 提交于 2019-12-11 04:27:41

问题


In my application i am accessing some web services that are in my local system. When i am invoking this services from my PC, these all working abs fine but when these services called from another system. on the call i am receiving the error

"org.xmlpull.v1.XmlPullParserException: expected: START_TAG".

Here is my code:

    public String getAccountsNames(int billId){

        String value = new String();
        System.out.println("Inside getAccountsDetails method...........");
        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
        request.addProperty("billId", billId);

        SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        soapEnvelope.dotNet=true;
        soapEnvelope.setOutputSoapObject(request);
        AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport(URL);
        try
        {
            androidHttpTransport.call(SOAP_ACTION, soapEnvelope);
            SoapPrimitive  resultString = (SoapPrimitive)soapEnvelope.getResponse();
            value = resultString.toString();
            System.out.println("This getAccountsNames xmls is : "+xml);
        }   catch (Exception e) {
            e.printStackTrace ();
        }
        return value;
   }

Also i have checked by setting SoapEnvelope.VER11, VER12, VER10. But the problem is same everytime.

Please suggest. thanks.


回答1:


Probably you're not getting an XML response when you're on other systems. You can see what you're getting this way:

androidHttpTransport.debug = true;
// ...
// execute the request
// ...
androidHttpTransport.responseDump; // <-- a string containing server response

Also: not that this might be the problem, but AndroidHttpTransport is deprecated, you should use HttpTransportSE.




回答2:


AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport(URL);

I had a similar issue and it was because I accidently inserted my NAMESPACE address instead of the URL, which was different. When I switched that back out, it worked.

As an added suggestion, if you are not seeing your parameter getting passed correctly, try excluding the line:

soapEnvelope.dotNet=true;

for me, I had a boolean value that was constantly being passed as false until I commented that line out.



来源:https://stackoverflow.com/questions/5791337/org-xmlpull-v1-xmlpullparserexception-expected-start-tag-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!