问题
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