Reputation: 1697
I'm calling an webservice which is soap based in my Android application. It is returning me the XML response. How can I parse it? I checked the XML parsing its asking for the URL. I'm confused about which URL I need to pass?
Here is the code:
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); request.addProperty("pStrType", type);
request.addProperty("pIntPageNo", PageNo)
request.addProperty("pIntPageSize", PageSize);
//Log.v(LOG_TAG," value:="+name);
//Log.v(LOG_TAG," value:="+pass);
SoapSerializationEnvelope envelope =
new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport(URL);
try
{
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapObject resultstring = (SoapObject) envelope.bodyIn;
Log.v(LOG_TAG," value:="+resultstring);
String Result=resultstring.toString();
What to do after this? I'm getting the string of response in (resultString).
Upvotes: 1
Views: 415
Reputation: 334
Try to use HttpTransportSE instead of HttpTransport and use object instead of soapObject try this code
HttpTransportSE http = new HttpTransportSE("http://10.0.2.2:2612/Service1.svc");
http.call("http://tempuri.org/IService1/GetCoursesInfos", envelope);
Object result= (Object)envelope.getResponse();
message=result.toString();
Check this code and tell me This post tells you how to consume soap web service
Upvotes: 0
Reputation: 39916
Disclaimer: I am going to suggest product of my own company, but its a good suggestion for this question.
You need to get some sort of Code generator like WSClient++
Upvotes: 0
Reputation: 1782
If you know how to use SAX XML Parser, you can convert the String into a byte stream and pass it to your handler.
String result=resultstring.toString(); SAXParser saxP = SAXParserFactory.newInstance().newSAXParser(); ResponseHandler respH = new ResponseHandler();//your implementation saxP.parse(new ByteArrayInputStream(result.getBytes()), respH);
If you don't know SAX parser, i would advice you to learn that first. It is simple.
Hope that helps.
Upvotes: 2