Search code examples
androidweb-servicessoapsoap-clientksoap2

Android and ksoup2


I'm trying to request some information from a server using ksoup2 for android. Here is the webservice SOAP info:

<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <HappySpeakGetEventsMethod xmlns="http://www.outsystems.com">
      <email>string</email>
      <password>string</password>
    </HappySpeakGetEventsMethod>
  </soap:Body>
</soap:Envelope>

And here is my Android code:

 try {
                SoapObject Request = new SoapObject(NAMESPACE, METHOD_NAME);
                Request.addProperty("email", "[email protected]");
                Request.addProperty("password","mypassword");

                SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
                soapEnvelope.setOutputSoapObject(Request);

                HttpTransportSE trnasport = new HttpTransportSE(URL);
                trnasport.debug = true;
                trnasport.call(SOAP_ACTION, soapEnvelope);

                Object resultsString =  soapEnvelope.getResponse();
                resultsString.toString();
            } catch (Exception e) {
                e.printStackTrace();
            }

The main problem is that the request gets to the server and both fields are empty(like this ""). Can anyone tell me what i am doing wrong?


Solution

  • Found the anwser! The namespace field was wrong and i had to add:

     soapEnvelope.dotnet=true;