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.
Related
I am developing an Android App. I read about RESTful Webservices and decided to use that for my app. But I have doubt about REST Client
After reading many article I understood that
I can directly write code to make HTTP request from android
App as given in Connenting To Network OR
I can write code to develop the RESTful client OR
I can use some already developed Third Party lib like RESTDroid
I am not able to decide should directly write code to make the HTTP request as suggested by developers guide or i should follow the rest client model.
What is the advantage of using rest client over directly making HTTP request ( or can say using non-RESTful Client) ?
I am new to android and REST architecture. Please correct me if I am wrong.
This is quite a broad answer but I will divide it in 2 parts:
1) Rest and non-Rest clients:
In my experience I have not seen any REST client except the browsers
the industry trimmed part of the original REST specification and created improved HTTP clients/services and called them REST which(most of them) are not different than any ordinary HTTP library.
So for Android you will get ordinary HTTP Clients with various features but the REST part you will need to code it yourself.
2) What is better to use
Clearly I would not advise to write your own HTTP client as it is far from trivial job to do.
I would not advise to use Retrofit for a really RESTful service as it is not good for that. You better build something on top of OkHttp or extend Volley or Jus which is my creation and it will support basic HATEOAS implementations from version 0.7.0 and optimized pipeline and memory utilization from version 1.0.0 (follow it on github :)
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
I have an online mysql database. I understand that to connect to it from an android app, I need to use a REST web service. From what I understood until now is that I have to use a REST webservice + JSON and Jquery to handle everything. But the things that I dont understand are:
do I need any coding to be done on my mysql web host domain?
this REST web service needs to be coded within my android app?
Do I need an apache http client, and that needs to be coded on my app or on the web host?
You're confusing database access, server side code and REST.
It is best practice not to go around directly connecting to databases from a client, especially a "locationally diverse" one.
Your architecture may look like
Android app ---HTTPS REST Verbs---> RESTful Webservices on server, hosed on Apache, Tomcat etc. --- Data access, be it via PDO, JDBC, JPA, whatever ---> mySQL.
The RESTful part really is optional, you can call into whatever you like if you're using an URL.
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.
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.