Best way of calling web service from an Android App - android

What is the best way to access a soap web service from an android device right now.
I see a lot of different approaches but I am not sure which way is the best.
Currently I need to create a small project where authentication is required to a SOAP base web service endpoint.
Any hints?

Use the KSOAP 2 library to communicate with your web-service.
You can find numerous tutorials for ksoap and this is good place to start.
EDIT:
If you require authentication to connect to the web-service, you would need to build the header of the soap request.
The following Stack Overflow questions should definitely guide you how to do the authentication.
how to set soap Header using ksoap2 - android
SOAP web service on android
Basic HTTP authentication using KSOAP for android
Blackberry kSoap2 & Soap Header
This post also talks about KSOAP and Authenticated web-services.

Hi see this example for KSOAP.
If you are using WSHTTPBINDING watch this.
Hope this will give you some information.

Related

Implement Jersey (JAX-RS) client library for php REST webservices on server

I have php webservices available on web server, I am trying to develop an Android project which will consume responses of those.
Jersey (JAX-RS) provides a client library to communicate with RESTful webservices, which can be used in my android app (client).
So I have some questions:
Does Jersey (JAX-RS) works with php webservices on server, or it needs Jersey web-services on server
If yes, Is it good idea to do it with Jersey
What are the other options which I have, to consume my php web services in android app
Yes you can consume your PHP web services in Android.
I advise to use Volley Framework (Google);Volley Framework
And here you can check many example:
Example Volley Frameworks
I have made some understanding about the topic since I asked about it, and here are some info If someone comes searching for the same thing later.
No need to learn a new thing: Jersey JAX-RS to consume the web services into an android app. (If you are not already into it.)
So to consume the web services into an android app, we have following options:
HttpURLConnection or Apache HTTP Client: Google has deprecated Apache HTTP client usage since Gingerbread. So you may use HttpURLConnection to request response to your web services.
Android Asynchronous Http Client: This is also a good library to consume REST responses into android app.
Volley: Google has created a library claiming it very faster.
library that makes networking for Android apps easier and most
importantly, faster.
And it follows RPC-style networking operations, also have interface so you can spend more time implementing your logic.
PS: Thanks Antonio for your suggestion.

which type of web services can a Android App talk to?

I was reading that SOAP is really not for Android. Rather Android prefers REST web services. So my question is, are there any other kinds of restrictions ? For example, some web services are built with JAXB. Is that ok for Android apps ?
I other words, does it matter how the REST web service is built ?
What if the web service returns data in XML format, is that ok with Android ?
It does not matter what kind of Webservice you are communicating with.
You communicate using HTTP protocol. If you use SOAP then you can parse your xml at client side.
Also there are many SOAP clients already available so you dont have to do much work.
Check this - http://code.google.com/p/ksoap2-android/
There is no restriction with REST web services on Android. Yes android can handle xml. You can get detail knowledge and help by going through GAE (Google app Engine). Find the link below:
https://developers.google.com/appengine/docs/
Android does not provide a built in SOAP client, there are many third party libraries that can be used to call a SOAP web service with native android APIs.
Where as REST is so simple & can be used directly without any third party libraries.

Create webservice in drupal

Can we create webservices in Drupal? Our web development team is creating a website in Drupal and they want to build an android application for the same and for that I need to use webservices to access the database.
Have a look at the services module
A standardized solution of integrating external applications with
Drupal. Service callbacks may be used with multiple interfaces like
REST, XMLRPC, JSON, JSON-RPC, SOAP, AMF, etc. This allows a Drupal
site to provide web services via multiple interfaces while using the
same callback code.
It's build for this reason. Drupalize.me android app is built on the services module, so too for many android applications.
Hope this helps... Muhammad.
Can we create webservices in Drupal?
Yes, You can Do it.
I had done it via JSON webservices.

KSoap2 or RESTful web services with android

What is the best way to deal with web services in Android?
I have been looking at KSoap2 library and RESTful web services.
I got one working with KSoap2, but only when the web service is on a remote server, not on localhost. I have tried to redirect the ports for incoming and outgoing as it says on the android dev site, i have used the ip of the network i am on, my own ip and the localhost-ip (it says on the site that one cannot use localhost cause that is the emulators own loop-back network. None works.
With RESTful webservices, i have only tried a tutorial where a google app engine is used as server if i understood it right. Is it easy to connect a RESTful web service to a database. I need to have a database connection in my applikation, which one is normally used with REST?
Sorry for the confused question, it's been many days of trying to sort just the alternatives out, and the more I look the confused I get.
THanks in advance for any help!
/AK
I would go for REST for sure. You could also use JSon instead of XML. Android has a built in support for JSon and REST becames quite easy to use and maintain with JAX-RS specification.
It is also as mentioned by Maks a light weigth approach.
If you have a more complex scenario you could use some JSon librarie like GSon for JSon parser between java objects and JSon.
Also if you decide to go for Seam in the server side I would suggest you to use RestEasy.
[]s
To connect to a webserver running on the same machine as your android emulator you need to use the IP address 10.0.2.2
see here:
Once you have your app in the emulator connecting successfully to a webserver running on the same machine you can then decide how best to send data between the two of them. If you choose to use XML and/or SOAP then kSoap2 is your best bet. Using a RESTful webservice is much more "light weight" and just refers to using normal HTTP and urls for your app to get/send data to the app running on your webserver.
check this Manual, when connecting Android to RESTful Web Services: Connecting RESTful Web Services on Android

Web Services with Android - why no support for WSDL?

I'm creating a Client/Server application with Android (Client) and WCF (Web Service).
From reading quite alot of discussions, I'm under the impression that there is no tool available to create the web service client in android automatically from a WSDL file.
If this is the situation, what is the easiest approach for creating a communication infrastructure between the client and server, that can be updated easily in the future (plain GET, REST, use SOAP and manually parse responses)
Initially, I wanted to build the web service and have the client created automatically with the provided WSDL file.
Thanks
AFAIK, there is no tool for automatic client generation based on a WSDL.
Android doesn't come with any soap related library.
BTW you can look for ksoap2-Android libraries and see if it's suitable for you.
More infos about using ksoap with Android should be found here

Categories

Resources