How to retrieve a soapObject from a webservice return

3
 androidHttpTransport.call(SOAP_ACTION4, envelope);
            SoapObject result = (SoapObject) envelope.getResponse();

            System.out.println(result.getProperty("nmConsultor"));
            return result.toString();

In case I would like to retrieve the properties contained in my return ...

Can anyone help me?

    
asked by anonymous 16.04.2014 / 16:20

1 answer

2

Using the ksoap2 v2.5.8 library, I do this:

public static String conectWs(String URL, String NAMESPACE, String METHOD_NAME, String strDataXmt, String param) throws Exception{

    HttpTransportSE androidHttpTransport = null;
    SoapObject request = new SoapObject(NAMESPACE , METHOD_NAME);

    request.addProperty(param, strDataXmt);
    //androidHttpTransport.debug = true;

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.setOutputSoapObject(request);
    envelope.dotNet = true;

    androidHttpTransport = new HttpTransportSE(URL);
    androidHttpTransport.call(NAMESPACE + METHOD_NAME, envelope);
    Object results = (Object) envelope.getResponse();

    return results.toString();
}

Then, to read this Result String as an Xml, I do this parse:

 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();  
 DocumentBuilder builder = factory.newDocumentBuilder();  
 Document doc = builder.parse(new InputSource(new StringReader(stringDeResultado)));  

 doc.getDocumentElement().normalize();
 NodeList nodeList = doc.getElementsByTagName("suaTag");
    
16.04.2014 / 23:35