0% found this document useful (0 votes)
31 views9 pages

Android Connecting To WebServices

SOAP is a protocol for exchanging information between applications over HTTP. In Android, the KSOAP2 library is used to call SOAP web services. A SoapObject is created containing the namespace, method name, and URL. Parameters are added to the SoapObject. A SoapEnvelope containing the SoapObject is then created. The web service is invoked, passing the SoapEnvelope, and the response is retrieved from the envelope.

Uploaded by

S Shiv Sharan
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views9 pages

Android Connecting To WebServices

SOAP is a protocol for exchanging information between applications over HTTP. In Android, the KSOAP2 library is used to call SOAP web services. A SoapObject is created containing the namespace, method name, and URL. Parameters are added to the SoapObject. A SoapEnvelope containing the SoapObject is then created. The web service is invoked, passing the SoapEnvelope, and the response is retrieved from the envelope.

Uploaded by

S Shiv Sharan
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Android Connecting to WebServices

Click to edit Master subtitle style

4/10/12

What is SOAP?

SOAP is a simple XML-based protocol to let

applications exchange information over HTTP.


Or more simply: SOAP is a protocol for accessing a

Web Service.

4/10/12

Soap for Android

We need Ksoap2 Android assembly Jar File

KSOAP relies on a basic object called SoapObject.

For this SoapObject, there are 3 variables that are

important: The Web Service Namespace The Web Service Method Name The Web Service URL

4/10/12

There is another extra variable which is important

and is called SOAP_ACTION, but that is basically a concatenation of the Namespace and Method name: SOAP_ACTION = NAMESPACE + METHOD_NAME;

4/10/12

Creating SOAP Object

SoapObject request = new

SoapObject(NAMESPACE, METHOD_NAME);

4/10/12

Passing Parameters
Parameters in KSOAP are passed

request.addProperty(Parameter Name", Value);

4/10/12

Then we will create another important KSOAP object,

and that is Soap Envelope:

Creating Object for Soap Envelop SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); Assigning Parameters : envelope.setOutputSoapObject(request);

4/10/12

Lastly, we need to invoke the web service and obtain the

result: AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport(URL); try { androidHttpTransport.call(SOAP_ACTION, envelope); SoapObject response = (SoapObject)envelope.bodyIn; String result = response.getProperty(0).toString(); } catch(Exception e) { e.printStackTrace();
4/10/12

Let us analyze this using an example

4/10/12

You might also like