-1

I have a .NET Web-services with asmx extension. The service http://www.web.com/SampleService/SampleService.asmx has two endpoints:

First is http://www.web.com/SampleService/SampleService.asmx/GetName which provides the name of the customers in the following format: enter image description here

Similarly, the second endpoint http://www.web.com/SampleService/SampleService.asmx/GetTax also returns some XML data.

I want to parse both of those xml data from the link http://www.web.com/SampleService/SampleService.asmx

I have read this tutorial which describes how to consume Web-services applications in the Android by using kSOAP2 - library. But in this tutorial, they explained how to pass the data to web and make some adding operation. But I need to parse the xml data from asmx link given above, and update the results to a ListView. How can I do this? Please anyone help me with a full example?

bCliks
  • 2,918
  • 7
  • 29
  • 52
  • Consuming ASMX WebServices using kSOAP2 is a lot of work. If you are in control of the WebServices, you might consider changing it to A REST/JSON API. It'll be fairly easy to consume it in Android. IF you have the control, AND time to change the services – RMalke Feb 22 '13 at 14:00
  • @RenanMalkeStigliani I'll consider your suggestion.. thank you.. – bCliks Feb 25 '13 at 12:57

1 Answers1

2
private static void parseResponse(InputStream is, SoapEnvelope envelope)
          throws Throwable {
        try {
          XmlPullParser xp = new KXmlParser();
          xp.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);                          

          xp.setInput(is, "UTF-8"); //UTF-8

          envelope.parse(xp);
        } catch (Throwable e) {           
            Log.e(LOG_TAG, "Error reading/parsing SOAP response", e);
            throw e;
        }
      }

....

parseResponse(is, envelope);
Object bodyIn = envelope.bodyIn;            
        if (bodyIn instanceof SoapFault) {
            throw (SoapFault) bodyIn;
        }

where is is the input stream from your web request. If parsing is ok, the bodyIn will contain SoapObject

mihail
  • 2,173
  • 19
  • 31