I have developed an android application through which I am downloading data in textfile from website using .net webservice. Now, since my data contains only 690 rows so reaching row 691 it is giving Unexpected token, so please tell me how should I apply a check to skip blank rows...The code I am placing below as well as Logcat
public static String invokeHelloWorldWS(String name, String webMethName) {
String resTxt = null;
// Create request
SoapObject request = new SoapObject(NAMESPACE, webMethName);
// Property which holds input parameters
PropertyInfo celsiusPI = new PropertyInfo();
// Set Name
celsiusPI.setName("name");
// Set Value
celsiusPI.setValue(name);
// Set dataType
celsiusPI.setType(String.class);
// Add the property to request object
//request.addProperty(celsiusPI);
request.addProperty("Content-Type", "text/xml; charset=utf-8");
// Create envelope
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.dotNet = true;
// Set output SOAP object
envelope.setOutputSoapObject(request);
// Create HTTP call object
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try {
// Invole web service
androidHttpTransport.call(SOAP_ACTION+webMethName, envelope);
// Get the response
SoapPrimitive response = (SoapPrimitive) envelope.getResponse();
// Assign it to fahren static variable
resTxt = response.toString();
} catch (Exception e) {
e.printStackTrace();
resTxt = "Error occured";
}
return resTxt;
}
Log cat
12-31 09:59:48.233: W/System.err(2856):
org.xmlpull.v1.XmlPullParserException: Unexpected token (position:TEXT
CONS_REF|BILL_MT...@691:1 in java.io.InputStreamReader@41222188)
12-31 09:59:48.293: W/System.err(2856): at
org.kxml2.io.KXmlParser.next(KXmlParser.java:426)
12-31 09:59:48.453: W/System.err(2856): at
org.kxml2.io.KXmlParser.next(KXmlParser.java:310)
12-31 09:59:48.483: W/System.err(2856): at
org.kxml2.io.KXmlParser.nextTag(KXmlParser.java:2029)
12-31 09:59:48.503: W/System.err(2856): at
org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:126)]
12-31 09:59:48.523: W/System.err(2856): at
org.ksoap2.transport.Transport.parseResponse(Transport.java:63)
12-31 09:59:48.653: W/System.err(2856): at
org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:100)
12-31 09:59:48.693: W/System.err(2856): at
com.prgguru.android.WebService.invokeHelloWorldWS(WebService.java:48)
12-31 09:59:48.723: W/System.err(2856): at
I searched for this problem alot and finally solved it. This problem is not for android coding, It is for .Net Service Binding.
In .Net web service on the server I changed service model to code below and it worked:
Old :
New :