-2

I am new to Android. Can anyone please help me to get started with Soap services with the help of Any example or source code ? Thanks in advance

S A
  • 19
  • 3
  • [enter link description here][1] [1]: http://stackoverflow.com/questions/1484122/android-wsdl-soap-service-client – Yack Apr 30 '12 at 12:12

2 Answers2

2

use this method if your webservice is .Net based:

private static SoapObject callWebServiceMethod(String url,
        String namespace, String methodName,
        HashMap<String, Object> parameters, String soapAction)
        throws Exception {

    Log.i("WebService", "URL: " + url);
    Log.i("WebService", "MethodName: " + methodName);

    URL myurl = new URL(url);
    URLConnection connection = myurl.openConnection();
    connection.setConnectTimeout(20 * 1000);
    HttpURLConnection httpConnection = (HttpURLConnection) connection;
    int responseCode = httpConnection.getResponseCode();
    if (responseCode == HttpURLConnection.HTTP_OK)
    {
        httpConnection.disconnect();
        SoapObject request = new SoapObject(namespace, methodName);

        if (parameters != null) {
            String[] keys = new String[0];
            keys = (String[]) parameters.keySet().toArray(keys);
            Object[] vals = (Object[]) parameters.values().toArray();

            for (int i = 0; i < parameters.size(); i++) {
                request.addProperty(keys[i], vals[i]);
                Log.i("WebService", keys[i] + ": " + vals[i]);
            }
        }

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

        envelope.setOutputSoapObject(request);
        HttpTransportSE androidHttpTransport = new HttpTransportSE(url,
                TimeOutInSeconds * 1000);


        androidHttpTransport.call(soapAction, envelope);


        SoapObject so = (SoapObject) envelope.getResponse();

        return so;

    }
    else
    {
        httpConnection.disconnect();

    }

}

for downloading Ksoap library use this link

Conscious
  • 1,603
  • 3
  • 18
  • 16
1

For use in SOAP Service in android you need to see Below Reference to Parse Soap:

Link To Soap service client

Link to Step by Step Use

Get ksoap jar to use in your android project from this ksoap2-android

Below is class for call Web-service for soap using ksoap library .

Community
  • 1
  • 1
Herry
  • 7,037
  • 7
  • 50
  • 80