How to consume SOAP/REST web services on Android (Service/Broadcast/Intent/etc)
-
Is there a common way to consume web services from Android applications (aside from the protocol)? What I need is a Service or Intent or Thread (or anything else) that is capable of: staying alive no matter what Activities are open; be able to perform multiple requests at the same time; accept input values and return output values to the right caller; be able to discard an ongoing operation (while keeping to run all the others) and not to return the output value if it is no longer desired; (of course) run asynchronously. Is there a common way to accomplish this? I've had some issues while using Services, primarily because I wasn't able to discard an ongoing operation, so the results were colliding with each other.
-
Answer:
mmm you need a combination of things here. First of all, you need a service layer implement it with a http://developer.android.com/guide/topics/fundamentals/bound-services.html (inherits). Your UI activities must call this service through an http://developer.android.com/guide/topics/intents/intents-filters.html. Then, this layer that would be execute it in a different thread than your UI layer, must have a Rest Client object to perform services calls. Here you have lot of approaches, I recommend you http://www.springsource.org/spring-android implementation as well as http://wiki.restlet.org/developers/172-restlet/g1/271-restlet.html. As is a pretty big discussion, anything else please tell me.
frapontillo at Stack Overflow Visit the source
Other answers
You should use Service for this task. This is the only component that was designed to handle background long-running tasks. Most likely you need to use this service as a "locally bound" to pass complex requests and responses without need for serialization, and to perform other tasks that are relatively hard to implement via Intents. Read more about locally bound services here: http://developer.android.com/guide/topics/fundamentals/bound-services.html.
inazaruk
This question was posted earlier on stack. Take a look at this thread http://stackoverflow.com/questions/3197335/android-restful-api-service You can also look at gdd sched, this is exactly what you want - http://code.google.com/p/gddsched/
Pradeep Sharma
Related Q & A:
- How To Send a Complex Object to a Rest Web Service?Best solution by codeproject.com
- How to create a Restful web service in .Net Using MySQL?Best solution by stackoverflow.com
- How to send SOAP request Android?Best solution by Stack Overflow
- How to manage android service?Best solution by support.google.com
- how to consume a web service in mule flow?Best solution by Stack Overflow
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.