Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to call a SOAP web service on Android [closed]

I am having a lot of trouble finding good information on how to call a standard SOAP/WSDL web service with Android. All I've been able to find are either very convoluted documents and references to "kSoap2" and then some bit about parsing it all manually with SAX. OK, that's fine, but it's 2008, so I figured there should be some good library for calling standard web services.

The web service is just basically one created in NetBeans. I would like to have IDE support for generating the plumbing classes. I just need the easiest/most-elegant way to contact a WSDL based web service from an Android-based phone.

like image 694
BobbyShaftoe Avatar asked Nov 18 '08 01:11

BobbyShaftoe


People also ask

How do I access SOAP service?

Select “Soap Webservices (supported by StrongLoop)” from the list of connectors. Enter http://www.webservicex.net/periodictable.asmx for “URL to the SOAP web service endpoint” prompt. Enter http://www.webservicex.net/periodictable.asmx?WSDL for “HTTP URL or local fie system path to WSDL file” prompt.


2 Answers

Android does not provide any sort of SOAP library. You can either write your own, or use something like kSOAP 2. As you note, others have been able to compile and use kSOAP2 in their own projects, but I haven't had to.

Google has shown, to date, little interest in adding a SOAP library to Android. My suspicion for this is that they'd rather support the current trends in Web Services toward REST-based services, and using JSON as a data encapsulation format. Or, using XMPP for messaging. But that is just conjecture.

XML-based web services are a slightly non-trivial task on Android at this time. Not knowing NetBeans, I can't speak to the tools available there, but I agree that a better library should be available. It is possible that the XmlPullParser will save you from using SAX, but I don't know much about that.

like image 80
foxxtrot Avatar answered Sep 28 '22 06:09

foxxtrot


org.apache.http.impl.client.DefaultHttpClient comes in the Android SDK by default. That'll get you connected to the WSDL.

HttpClient httpClient = new DefaultHttpClient(); HttpContext localContext = new BasicHttpContext(); HttpGet httpGet = new HttpGet("http://www.example.com/" + URL); HttpResponse response = httpClient.execute(httpGet, localContext); 
like image 31
Neil Avatar answered Sep 28 '22 05:09

Neil