I'm making an app that is requesting data from a Web Service (implementing Soap).
People who are viewing this pleaase post doubts in comments... I havent got any response to the question do ask me if there is any doubts, i really need help, am stuck!!
So to make request I have to use ksoap libraries.. the Web service is coded to return a response of type XML. When the web service itself is tested on a browser it displays a result which is as follows:
?xml version="1.0" encoding="utf-8" ?>
- <SOBKeyList>
- <Key>
<value>12686</value>
</Key>
- <Key>
<value>16238</value>
</Key>
- <Key>
<value>26978</value>
</Key>
</SOBKeyList>
clearly an XML file...
However
when i use ths code to get a result:
public String getXmlFromUrl(String url) {
// TODO Auto-generated method stub
String xml = null;
SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE,OPERATION_NAME);
PropertyInfo pi = new PropertyInfo();
pi.setName("fkey");
pi.setValue(0);
pi.setType(Integer.class);
request.addProperty(pi);
pi = new PropertyInfo();
pi.setName("tkey");
pi.setValue(999999);
pi.setType(Integer.class);
request.addProperty(pi);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE httpTransport = new HttpTransportSE(url);
Object response = null;
try {
httpTransport.call(SOAP_ACTION, envelope);
response = envelope.getResponse();
xml = response.toString();
Log.d("xml:", xml);
} catch (SoapFault e) {
// TODO Auto-generated catch block
Log.d("Soap Fault", e.toString());
} catch (IOException e) {
// TODO Auto-generated catch block
Log.d("IOexception", e.toString());
} catch (XmlPullParserException e) {
// TODO Auto-generated catch block
Log.d("XmlPullParserException", e.toString());
}
return xml;
}
It returns a nested SOAP structure confirmed by the Log entry which i make ( Log.d("xml:", xml);
)
The corresponding LogCat entry is: (i've formatted it to make it the SOAP structure's heirarchy apparent... )
anyType{
SOBKeyList=anyType{
Key=anyType{value=12686 ; };
Key=anyType{value=16238 ; };
Key=anyType{value=26978 ; };
};
}
The reason why i necessarily need an XML is because later I parse the string to get a DOM element and when the above string is passed it returns the following:
org.xml.sax.SAXParseException: Unexpected token (position:TEXT anyType{SOBKeyLi...@1:119 in java.io.StringReader@40ec9c68)
also from there onward my entire code depends on the fact that the response was XML.
Explaination of the reason why i expected an XML : Now you may asked why I coded my app expecting XML when i had not tested the Web service the reason is: The Web service was coded my a third party who assured me of an XML response , now i dont have enough time to change my remaining code to exploit a SOAP structure !! -_- I'm in a fix. Please help!