I'm developing a server-client application. It is a service that is supposed to be used by thousands of users so it should scale well. The server side is done in Spring + JPA(Hibernate) and it provides about 80 API methods. There will be multiple clients - GWT webapp, mobile devices clients (iOS, Android, Windows) + a simple desktop client (Eclipse RCP / To be decided).
I'm considering various ways to connect to the server side. My ideas are (maybe there are some other, better ways):
Use SOAP Webservices to expose server API to all the clients
SOAP WS are considered to be slow and I don't know it can handle all the communication
Android doesn't officially support SOAP WS (bu there are some 3rd party libs)
Use RESTfull WS to handle communication
better performance than SOAP
official support on all the mobile devices
may be difficult to access RESTfull WS from non-web, desktop client
Use REST WS for mobile, GWT Request Factory for webapp
Request Factory is recommended way to communicate with GWT client (at least it was on 2009 Google I/O). I suppose it should perform better than Web Services?
Which solution (listed above or not) would perform best and be the most productive for developers?
If you've worked on a similar project, I'd love to know your opinion :)
I'd vote for Using RESTful services on the backend, and interacting with that from the front end of your choice.
This gives you the most flexibility in terms of serving multiple clients. For instance, you can end-of-life a front end technology without having to remove any server side code, or you can introduce a new front end without any back end changes.
If you avoid trying to support both REST WS for mobile and GWT-backed server side classes (such as GWT-RPC) for webapp, you will have the following advantages:
Single back end to develop and test: do not underestimate this!
Ease of monitoring network traffic to debug what either end actually sent. GWT network traffic is not so easy to debug, I'll take JSON over GWT-RPC any day.
Don't worry about one technology or another not being able to consume your services: REST WS is becoming so popular that there are a variety of ways to use those services from any front end. For instance, a GWT app could use GWT overlays to map JSON responses to GWT/Java objects, and a desktop client could use Apache HTTP Client.
If your webservices are RESTful, I will recomend you RestyGWT.
I used it a long time ago and it works pretty well.
Related
I want to develop a Java server that is able to send messages asynchronously to a client in form of a website with JavaScript. I know that one possibility is using WebSockets, but these are not supported in IE 9.
For transmitting messages from client to server I can use AJAX calls with maybe a RESTful Interface on the server side.
Does anyone have a solution for this?
This is not how webservers work, most of the time. HTTP Webservers are inherently a request-response architecture:
HTTP functions as a request-response protocol in the client-server computing model. A web browser, for example, may be the client and an application running on a computer hosting a web site may be the server. The client submits an HTTP request message to the server. The server, which provides resources such as HTML files and other content, or performs other functions on behalf of the client, returns a response message to the client.
That said, there are technologies that you can use to do this. Read here about Comet and Reverse AJAX:
Is there some way to PUSH data from web server to browser?
You better implement your Java server to act as a Websocket server when it's supported by the end user. For the users who does not support Websocket it should fall back to long-polling.
This behaviour will avoid unnecessary overheads due to long-polling communications whenever possible.
The good thing is you don't have to implement all these behavious from the scratch. You can readily embed and use a reliable implementation available open source.
One such implementation is CometD project. The CometD project was available for more than a decade and it has evolved to solve most of the issues.
If you are looking for commercial products, there are many available. One such would be lightstreamer (http://www.lightstreamer.com).
You need to use a design pattern like long polling since WebSockets is not available. Rather than build it yourself you could use a library like SignalR. SignalR is an ASP.NET library but there is a client for Java (https://github.com/SignalR/java-client)
For anyone who comes across this question more recently, the modern answer (as of early 2021) supported across all browsers (except IE, which even Microsoft has given up on in favour of Chromium-powered Edge) are server-sent events. A most elegant and standardised solution to providing a pub/sub model to web clients.
I am a GWT user and what I appreciate of it is the opportunity to develop web interfaces in Java.
Currently, a team is developing the server side of a web application that offers rest Apis and that is based on Spring.
My idea was to use GWT to create the client side application and, rather than invoking some gwt rest apis, I want to invoke, from such client, the rest apis exposed by the spring-based server.
My questions are: does this sound reasonable? Can i just code and cross compile a gwt client invoking the external rest Apps or do I still need GWT server handing off the requests to the spring-based server? What's a potential deployment scenario? Thanks.
You don't need GWT server capabilities at all (gwt-server.jar). You only need a web server to host your compiled GWT app like nginx.
What works for me is coding simple REST calls (Spring MVC) from the server and GWT using GWTP Rest support.
Jackson and GwtJackson are used in both sides to serialize/deserialize DTO's.
To avoid SOP problems use a reverse proxy or implement CORS.
Here is the background of my situation:
I want to create an iPad application that interacts with a oracle SQL database. I have existing Java code from my Flex application that handles all the database requests, and modifications using the Spring Framework. The Flex Application ran as a web service through TomCat. Now I want to make that flex application into a mobile iPad version. I am having trouble figuring out what is the easiest way to use existing Java code and use it for the iPad because the iPad interacts using URL requests instead of direct with the Java.
My question is, can I use the existing Java code with the Spring framework to save time from coding all the back-end handling? Basically I want to access all the classes from my Java code by doing Requests from the iPad. Is this possible and will I need JSON or XML to interact between the iPad and the Java code?
Summary:
Can I use
iPad Objective-C <-----> Java (with spring framework) on TomCat Web Service to handle oracle SQL data handeling? If so, how and what technologies do I need? Will I need JSON or XML and how does that factor between the iPad and Java?
Thanks!
A good approach would be to design your app to communicate with RESTful services that return JSON. Once this is done your iPad app doesn't have to even know that the server code is written in Java.. it's just interacting over HTTP.
Here's a good tutorial on setting up your tomcat to host your RESTful services: http://www.vogella.com/articles/REST/article.html - I've used this for an app I'm developing. Spring isn't even necessary.
You could go XML, but JSON is just easier in my opinion. Here's a good blog outlining the good and bad of both sides. http://digitalbazaar.com/2010/11/22/json-vs-xml/
OK, I'm making the following presumptions.
Your flex application runs on a different machine from the Tomcat
server
Your flex application makes web service calls to the Tomcat server
So, the flex application doesn't know the underlying technology that provides the web services. It's just seeing/consuming the output
There's no reason why the iPad app can't do the same thing. There's no reason why it can't use the same web services that the Flex application uses. It could consume the same messages (Assuming it can handle the request/response format currently employed by the Flex application).
You can make changes if you like if you want to change the structure of the requests/responses between the clients. But the clients don't know (nor care) how the web services are implemented. They are just requesting and consuming info.
In my java based web application (struts 2 and hibernate 3). I have made a web-service using apache axis.
The web-service has to return data from the database which will be used by the android application.
Now, that service obviously has to be published on a public ip so that I can access it in the android app.
What are the options to publish it on free public ip's or domains ?
Would it be better if I use REST instead of apache-axis to make a web-service? What is JAX?
And for android developers , How a web service is consumed in android?
Please answer its urgent and important.
In order to publish on the web you need to put it on a web enabled server, you can do it in several ways:
Turn your computer to a server (thuis is one article, just search in google "how to turn my computer to web server").
Upload your files to a free host
Upload your files to a paid host (usually for a very small fee)
REST vs SOAP (apache-axis):
I would recommend going with REST as it is more lighweight and more flexible (it enables you to get a response as xml,json,html while soap is usually just XML).
JAX-RS id java API for creating REST web services. Look at the jersey framework.
AJAX is a way to send/get data asynchronously and is used wideley in web applications.
How a web service is consumed in android can wideley vary depending on the technology you are using.
I know node.js is usually used to server as a backend to backbone.js, but can netty also do this?
I prefer the jvm, and was hoping someone could provide some production worthy code that serves as a backend to backbone.js.
And the main point of this is to be able to have a real-time web application, so it would use long-polling to maintain a connection with the client to update the UI (say someone updated something via a mobile device, the browser should react to this).
Backbone is 100% backend agnostic.
Our entire site is built on top of Backbone for the front-end and the backend is entirely in Java.
Personal projects have used Python and Flask to handle the API layer.
Backbone was originally culled from a RoR project...