Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Call .NET Webservice with Android

I know this question has been asked here before, but I don't think those answers were adequate for my needs.

We have a SOAP webservice that is used for an iPhone application, but it is possible that we need an Android specific version or a proxy of the service, so we have the option to go with either SOAP or JSON. I have a few concerns about both methods:

SOAP solution:

  1. Is it possible to generate java source code from a WSDL file, if so, will it include some kind of proxy class to invoke the webservice and will it work in the Android environment at all?
  2. Google has not provided any SOAP library in Android, so i need to use 3rd party, any suggestion?
  3. What about the performance/overhead with parsing and transmitting SOAP xml over the wire versus the JSON solution?

JSON solution:

  1. There is a few classes in the Android sdk that will let me parse JSON, but does it support generic parsing, like if I want the result to be parsed as a complex type? Or would I need to implement that myself?
  2. I have read about 2 libraries before here on Stackoverflow, GSON an Jackson. What is the difference performance and usability (from a developers perspective) wise? Do you guys have any experince with either of those libraries?

So i guess the big question is, what method to go with?

I hope you can help me out. Thanks in advance :-)

like image 889
Lasse P Avatar asked Jun 07 '10 18:06

Lasse P


People also ask

Can asp net run on Android?

Mobile apps can communicate with ASP.NET Core backend services. For instructions on connecting local web services from iOS simulators and Android emulators, see Connect to Local Web Services from iOS Simulators and Android Emulators.


1 Answers

I cannot talk much about the JSON solution. But I've been working with SOAP on Android for a while.

Here are my comments regarding the SOAP solution.

  1. The most popular library that I've found for doing SOAP on Android devices is kSOAP.
  2. The default kSOAP library doesn't provide a way to generate Java classes from a WSDL. It is a big problem if you have a WSDL with a lot of method. I found a project (http://en.sourceforge.jp/projects/sfnet_wsdl2ksoap2/) that "claims" to do it. NOTE: I've not used this successfully yet. I discovered it after I had implemented the current version of my code.
  3. XML parsing has an overhead and sometimes it can be a problem. The parsing overhead will depend on your application context and performance requirements. Currently, I'm getting acceptable performance by using SOAP to send video frames (SOAP containing base64 encoded MJPEG frames.) For large messages parsing time on a Nexus One are of the order of a 150-200 ms (depending on the message size.)

This may be unrelated but I found this Google I/O session on building RESTFul applications for Android useful. I think they also released a JSON API in 2.2

Hope this helps.

like image 102
Soumya Simanta Avatar answered Sep 30 '22 17:09

Soumya Simanta