Search code examples
androidsoapwsdlksoap2android-ksoap2

Android and SOAP Webservice


I'm trying to interface my Android application with my SOAP webservices, and I get unexpected results...

Soap services are working fine, they've been tested with SoapUI, WSDL is valid. I'm using ksoap2 lib version 1.6.1

Here is my calling code :

    try {

        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
        request.addProperty("prop1", 1);
        request.addProperty("prop2", "FR");
        envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.setOutputSoapObject(request);
        androidHttpTransport = new HttpTransportSE(URL);
        androidHttpTransport.debug = true;
        androidHttpTransport.call(SOAP_ACTION, envelope);
        SoapObject objetSOAP = (SoapObject)envelope.getResponse();
        Log.e("TESTSOAP", objetSOAP.getProperty(0).toString());
    }
    catch (Exception e){
        Log.i("androidHttpTransport.requestDump", androidHttpTransport.requestDump);
        e.printStackTrace();
        Log.i("androidHttpTransport.responseDump", androidHttpTransport.responseDump);


    }

I got an exception at the "call" method, wich is :

03-13 17:31:05.791: W/System.err(6020):     at 03-13 17:30:19.901: W/System.err(5976):            org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope (position:START_TAG .... @2:402 in java.io.InputStreamReader@46294968) 

What is weird is that if I use the requestDump to get the sent envelope in SoapUI to try it out, it works perfectly fine. I got the expected result. But the responseDump is actually returning me the wsdl file, and not the result. Just like if the wsdl was called fine, but not the method i'm trying to invoke.

Anyone got an idea on why ? And maybe how to correct it ?

Thanks !


Solution

  • Damn it, finally found a solution (months after!) Apparently,

       androidHttpTransport = new HttpTransportSE(URL);
    

    Should point not to the wsdl, but to the php file.