0

I'm consuming asmx web service in my code which does not return proper XML file. Here is my code

private static final String SOAP_ACTION = "http://tempuri.org/ValidateLogin";     
private static final String METHOD_NAME = "ValidateLogin" ;     
private static final String NAMESPACE = "http://tempuri.org/";     
private static final String URL = "http://ufindfish.b4live.com/FindFish.asmx";     

request= new SoapObject(NAMESPACE,METHOD_NAME);
request.addProperty("sUserName",name);
request.addProperty("sPwd", password);


//envelope.bodyOut=request;
envelope=new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet=true;
envelope.setOutputSoapObject(request);
envelope.encodingStyle=SoapSerializationEnvelope.XSD;
//generate httpresponce
httpTransportSE=new HttpTransportSE(URL);
try {
    httpTransportSE.call(SOAP_ACTION,envelope);
} catch (IOException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
} catch (XmlPullParserException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
}

SoapObject result = null;
try {
    result=(SoapObject)envelope.getResponse();
    //Log.i("RESPONCE",""+result.toString());
} catch (SoapFault e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}

response is below...what should i do?

anyType{NearLake=anyType{tblNearLake=anyType{LAKE=2022C01 BENSFORT BRIDGE to PETERBOROUGH; LAT=11.622; LON=20.616; }; tblNearLake=anyType{LAKE=2022C01 BENSFORT BRIDGE to PETERBOROUGH; LAT=11.186; LON=19.443; }; }; }

please help me...

Thanks in advance

Nipun
  • 990
  • 1
  • 16
  • 25
devaki
  • 1
  • How are you checking what result is incorrect? You can't rely on result of toString() method while checking it! – Olegas Apr 13 '11 at 12:04
  • @Olegas result is ok...but its not giving me proper xml file to parse it. – devaki Apr 13 '11 at 12:20
  • How are you trying to parse it? Why you want t oparse it separately? Isn't it already parsed by your SOAP library? – Olegas Apr 13 '11 at 12:31
  • i have no idea whther library parse it already...bt whatever i have read so far i got info that u get the xml file and u'll parse according to ur need... hav u used this service b4?did u get xml file? – devaki Apr 13 '11 at 12:39
  • No i didn't have used SOAP in Android, but i know what SOAP is a some kind of RPC protocol to do a call and receive a strongly typed answer. What SOAP library are you using? – Olegas Apr 13 '11 at 12:46
  • see http://stackoverflow.com/questions/3092424/parsing-ksoap2-response and http://stackoverflow.com/questions/3950862/parse-ksoap2-response-in-android and http://www.helloandroid.com/tutorials/using-ksoap2-android-and-parsing-output-data – bigstones Apr 13 '11 at 13:10

1 Answers1

1

I struggled a lot with this issue and finally got solution. The following code will do the job for you.

 httpTransportSE.debug=true; 
 httpTransportSE.call(SOAP_ACTION, envelope);
 String ss=httpTransportSE.responseDump;
 Log.d("--Result-- ", ss);

It will print the webservice output with xml tags properly if that web service returns a xml.

Hasanur
  • 146
  • 7