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. 4/10/12 . Or more simply: SOAP is a protocol for accessing a Web Service.

there are 3 variables that are important: The Web Service Namespace The Web Service Method Name The Web Service URL 4/10/12 .Soap for Android We need Ksoap2 Android assembly Jar File KSOAP relies on a basic object called SoapObject. For this SoapObject.

4/10/12 . but that is basically a concatenation of the Namespace and Method name: SOAP_ACTION = NAMESPACE + METHOD_NAME.There is another extra variable which is important and is called SOAP_ACTION.

4/10/12 . METHOD_NAME).Creating SOAP Object SoapObject request = new SoapObject(NAMESPACE.

Passing Parameters Parameters in KSOAP are passed request. Value). 4/10/12 .addProperty(“Parameter Name".

setOutputSoapObject(request). and that is Soap Envelope: Creating Object for Soap Envelop SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope. 4/10/12 . Assigning Parameters : envelope.Then we will create another important KSOAP object.VER11).

we need to invoke the web service and obtain the result: AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport(URL).toString(). String result = response.printStackTrace(). envelope). } catch(Exception e) { e.call(SOAP_ACTION. SoapObject response = (SoapObject)envelope. Lastly.bodyIn. 4/10/12 . try { androidHttpTransport.getProperty(0).

Let us analyze this using an example 4/10/12 .

Sign up to vote on this title
UsefulNot useful