Search code examples
androidsoapksoap2

Is there a problem with ksoap2 and soap Version 12?


I tested calling a soap 12 webservices with ksoap2. I used this code to call the webservice:

SoapObject request = new SoapObject(NAMESPACE, NAME);
request.addProperty("id", ID);
request.addProperty("name", "test@test.de");
request.addProperty("pw", "password");
request.addProperty("listid", 501);

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER12);
envelope.setOutputSoapObject(request);

AndroidHttpTransport client = new AndroidHttpTransport(URL);
try {
   client.call(NAMESPACE + NAME, envelope);
   Object response = envelope.getResponse();
} catch (IOException e) {
   Log.e(getClass().getSimpleName(), "IO Problem", e);
} catch (XmlPullParserException e) {
   Log.e(getClass().getSimpleName(), "Parser Problem", e);
}

I now get the following exception:

org.xmlpull.v1.XmlPullParserException:expected: START_TAG {http://www.w3.org/2001/12/soap-envelope}Envelope (position:START_TAG <{http://schemas.xmlsoap.org/soap/envelope/}soapenv:Envelope>@1:114 in java.io.InputStreamReader@44f28a80)

Is this a problem of the server response or is there something wrong in my code so far? It seems that other users have the same problem. If I change the Envelope to SoapEnvelope.VER11 I get a step further (I get an access denied response from the soap server probably because of a wrong URL) maybe there is additional info missing to create a VER12 envelope.


Solution

  • Have you tried the various options for your envelope to see what the services expects?

    E.g. you can set

    envelope.dotNet = true;
    envelope.headerOut = security; // this is an Element[] created before
    envelope.encodingStyle = SoapEnvelope.ENC;
    envelope.setAddAdornments(false);
    envelope.implicitTypes = false;
    

    and a bunch more. Check out the javadoc?

    Also make sure to use the latest release of the ksoap2-android project to get a bunch of fixes that are not in the normal sourceforge project.