Client server protocol in Android - android

I am designing an application on Android which is based on client/server structure.
I want to work with Interface object which are shared between the client and the server such like RMI, or web service
For example the client calls createCustomer(Icustomer Data)
And the server implement this method.
It’s very important for me to make serialization of the interfaces over the network.
What is the common and the efficient way to do this Android?

JSON, as implemented in the API or as implemented by gson, or xml.

One approach I have done for client/server model is with JAX-WS(in my example my server was a glassfish server with exposed SOAP webservice methods. Glassfish JAX-WS)
I then consumed the XML SOAP messages on the client(android app) using ksoap2-android libraries(ksoap2-android webpage) since they are lighter weight than the clunky JAXB libraries(However, the JAXB would be easier to work with).
If you want to go with this approach I can share with you some code samples, and how I made KSoap2 easier to work with.
Keep in mind JSON in terms of efficiency is more efficient than SOAP because of the overheads associated with SOAP.

Related

Android and Webservice

I am working on android project that connects to a database,
while I'm looking for tutorial I found ones that creates .php files and connect them with the android app using HttpClient and HttpPost,
and then exchange data with json.
this one is clear.
I found also other toturials that confuses me!
they are talking about using SOAP and wsdl files??
the links they were using for connecting to web service was with .wsdl extension!
Can someone explain to me what are they?
Thank you.
SOAP EN WSDL have something to do with xml, I dont recommend you to use xml either.
I recommend you to use json, because performance of json is better than xml.
I highly to recommend you to use volley https://developers.google.com/events/io/sessions/325304728
There are enough examples on the internet to make it work very well with your application!
However if you want to make a webservice see the question here > Android WSDL/SOAP service client
WSDL is an XML format for describing network services as a set of endpoints operating on messages containing either document-oriented or procedure-oriented information. The operations and messages are described abstractly, and then bound to a concrete network protocol and message format to define an endpoint. Related concrete endpoints are combined into abstract endpoints (services). WSDL is extensible to allow description of endpoints and their messages regardless of what message formats or network protocols are used to communicate, however, the only bindings described in this document describe how to use WSDL in conjunction with SOAP 1.1, HTTP GET/POST, and MIME.
source:http://www.w3.org/TR/wsdl

What type of web service should I use for consumption by iOS/Android apps?

I have to write some web services to support some mobile apps (Android and iOS) that our company will be producing. Because we use Windows/IIS servers the services will be based on WCF/.NET 4. I'm wondering what format will be the easiest to use on the mobile end. I know there's JSON, SOAP, and others, I just don't know which has the best support within a mobile environment. Suggestions?
I intend to have a single set of WCF services which are consumed by both mobile platforms.
Since you're using the .NET-platform on the server, WCF supports sending/receiving XML or JSON messages pretty easily using WebHttpBindings and WebServiceHostFactory to build RESTful services.
For the client platforms - you just need an HTTP Client capable of sending JSON or XML formatted messages to a URL and retrieving a response. There are many libraries that will make this easier to manage, but it depends on the complexities involved in your service.
I would avoid SOAP, but you can easily support it using WCF by adding BasicHttpBinding and a ServiceHostFactory.
For my experience, working with JSON is the best way for iOS and Android.
The server... I would use Java (struts or similar).
Hope this helps
I used the Slim framework (PHP) to serve JSON via RESTish URLs, and the GSON library to convert the data, it was pretty straight forward in my case.
I use apache Camel CXF (web service) & to parse the data I use JAXB.
note: about cxf http://camel.apache.org/cxf.html

Android ReST based client and SOAP server. Is it possible?

I'm writing a web-service for Android. The client side will be coded in JAVA and we are planning on using ReST. But, the server supports SOAP, JMS( Java Messaging Service) and Remote Method Invocation (only these). I just want to know if it is possible to return response for a ReST based client from this server.
As far as I know, ReST is not a protocol like SOAP, but I just want to be sure that it can be done before I get started.
Any link to video/tutorial/code will also do.
Thanks in advance.
REST is really just an elegant way to use HTTP for resource access.
HTTP is the protocol.
So if you can process HTTP requests on that server, it's doable.
In a Java EE environment a servlet container is perfect: you can create a WAR based on the Jersey framework.

I want to implement a RESTful webservice do i need something om my server running to handle requests , like with SOAP

I want to implement a RESTful webservice for an Android App using JSON. Do i need something om my server running to make for example a GET request work , like with SOAP is the case. I have read something on servlets but i don't know if this is neccesary or not.
If you will be using PHP on the server then you can write a RESTful service with a PHP application framework like Kohana, CodeIgniter, CakePHP etc. There are quite a few.
These frameworks have built in functions for encoding results in JSON format and they support the REST approach out of the box.
If you prefer I'm sure there are also similar IIS and .NET based approaches too.
If you query your own server, then you need to first program your server to handle requests. On the other hand, if you query a 3rd party RESTful server, then all you need is create the appropriate http request, send it and handle the response.
Servlets are used for Java EE based implementations of servers. You can implement your server in any programming language or framework you want.

Android application consuming WCF

I'm new in Android and I have to do an application (in android) that consumes a NET WCF service with httpbasicbinding. I have heard about use of ksoap2-android, json and restfull but I don't know which is the best way for my app.
Anyone can suggest me anything?
Another problem is my WCF service return complex objects made by Linq To Sql and I don't know how can I use it in Android.
Thanks in advance!
If you use oData web services you can use the odata4j client library.
If you're using Service Stack to develop your web services you can use any REST client to easily consume them (in any format i.e. JSON, XML, JSV, SOAP, etc). The Hello World example shows a number of different ways you can consume a single web service.

Categories

Resources