I need some advices.
I’ve a WSDL and I need to call some services.
For you, What is the best way to callSOAP web service with Android?
I know that we can:
- use the library
Ksoap 2 - create
xmltemplates and send them by a simplehttp protocol. - Or i can do something like:
public class AppelService {
private static final String NAMESPACE = "http://my-website.com";
private static final String URL = "http://mon-example-web-services/wsdl.WSDL";
private static final String SOAP_ACTION = "getWeather";
private static final String METHOD_NAME = "getWeather";
private String getWeather(String city) {
try {
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("city", city);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport(URL);
androidHttpTransport.call(SOAP_ACTION, envelope);
} catch (Exception e) {
Log.e("getWeather", "", e);
}
}
}
From your own experience, what do you think is the best way to do it ?
any help is appreciated.
Thanks.
I would definitely advocate using ksoap2-android libary. I have done this very research, and nothing beats using this library in terms of versatility.
The code you have provided is ksoap2.
From the ksoap2-android website: