Play Framework Bi-directional support including older browsers - scala

I'm about to build a web application in Play Framework and I'll need to have bidirectional communication between the server and the browser.
For modern browsers I can use web sockets, but for older browsers I will need to use long polling. Is there a library that will abstract away this choice and choose whichever one is supported by the browser? Similar to SignalR in .net.

It seems like the Atmoshphere library is absolutely what I was looking for. https://github.com/Atmosphere/atmosphere

Two good options nowdays:
SignalJ based on SignalR https://github.com/chanan/SignalJ using Akka and integrated in Play and with good integration with SignalJ web servers (based on .net)
Atmoshphere library https://github.com/Atmosphere/atmosphere that also supports Play integration and multitude of frameworks

Related

REST API, WebSocket and ZeroMQ in Scala. What to use?

Let's say I have some service that talks over ZeroMQ sockets, and I want to provide access to that service to a single-page web application. I'd like the web app to talk to a service that provides a REST API (for control and queries) and WebSockets (for monitoring), and which does this by talking ZeroMQ to the first service. I'd like to write this in Scala.
What options are available to me for building that second service?
A very integrated solution would be to use Akka/Play2 for this.
Akka would be the core component talking to the ZeroMQ socktes via akkas ZeroMQ Module, which gives you a nice Scala-API and Akka/Actor integration. This Akka/Actor system can than be accessed via HTTP/WebSockets by using either play-mini or play2 which mainly differ in the style of defining HTTP endpoints.
For REST API I would recommend Spray - a nice library with a very concise and flexible DSL for defining web services. We've integrated Spray into our current project and are pretty happy with it. As for play-mini, AFAIK, it depends on the entire play2 project, so you'll end up with a lot of stuff you don't need.

GWT and WebSocket / Push data from server to GWT client

Is there any good library which supports WebSockets and is compatible with GWT? Ideally, the library would support WebSockets as well as a fallback for browsers which don't support WebSocket, e.g. a comet-like approach or polling.
I'm currently using GWT-Comet to push data from my server to my GWT web application. However, this library is a bit broken in some aspects and it seems it's not maintained actively anymore. Thus, I'm searching for an alternative.
I found Atmosphere, which suits the needs stated in the question pretty good. It supports GWT, and also Websockets. Also, it supports many different application Servers, like Tomcat and Jetty.

Pro and Cons to create a REST architechture using [SPRING MVC] or [GWT + MVP] (and using spring ROO)?

I am asking this question because, I see that Roo include SPRING MVC and GWT...but
- GWT (on its website) shows an example of a MVP pattern but I think it is not comparable with the SPRING MVC framework (indeed Spring MVC has more features. I have never used it...but I read that it helps a lot to do website, and easily lets have a REST architecture (how to do as easily a REST architecture with GWT and a MVP plateform ?)...
Can you help me to choose between these technologies (taking care that I want to develop my app on GAE, and I will also want Mobile phone version) ?
I suggest you not to use GWT with Roo, its GWT support extremely buggy at the moment. (Saying this as a big fan of Roo)
Also, REST is architectural style which embraces HTTP as an application protocol, not only as a transport protocol, meanwhile GWT is a framework, or rather a toolset for creating rich web application which use JavaScript as a frontend, one has basically nothing to do with the other. You can however use Spring MVC to build RESTful applications:
http://blog.springsource.com/2009/03/08/rest-in-spring-3-mvc/
http://static.springsource.org/spring/docs/3.0.0.M3/spring-framework-reference/html/ch18s02.html
http://www.oudmaijer.com/2010/01/16/spring-3-0-rest-services-with-spring-mvc/

[iPhone and Web Services]: REST vs SOAP

I've started my degree project, a mobile application suitable for iPhone, Android and (in the near future) Symbian. The server architecture is the following:
web site (for "standard" users);
web service (for mobile connections), based on TomCat and Axis2;
mySQL DB to storage users data.
Surfing across the web, I've read a lot of discussion about the interaction between the iPhone and Web Services, and I've to say that I've not a clear idea of what I can do and what not.
Let's start from the protocol used to retrieve data from the DB: the Android-side application uses SOAP protocol, can I do the same with iPhone? Are there some limitations or problems?
I have also read about the using of REST instead of SOAP, could it be possible with the server architecture described above? Which are the main advantages/disadvantages?
Sorry if these questions sound "n00b", but it's my first real experience with iPhone and the lot of informations found on the web messed up my mind and I'm scared to be confused. Forgive me for any error.
SOAP is simply too heavy for mobile communications. Why do all the work to wrap requests in an additional XML layer you'll have to parse? You send more data than you need to, and impose greater CPU burden on client and server.
Use REST. If you are doing a cross-platform project JSON makes a great payload container, otherwise plists work well for sending data from the server.
You can definitely do SOAP on the iPhone. Here is a nice tutorial on the subject. After all, SOAP is a HTTP based protocol and you have all the libraries you need to do HTTP on the iPhone.
Having said that, RESTful APIs are simpler than SOAP, so you might want to consider them. They're also HTTP based so you won't have any problems on doing that on iPhone. On the server side, if you use Java, you will have to use JAX-RS to implement that part.
Hope it helps.
Google Buffers
If your looking for a language and platform agnostic solution have a look at Google Buffers. You can easily serialise objects for transmission over the wire.
This question should get you started in Objective-C.
JSON
I have also used JSON within iPhone Apps with great success. Again, relatively language and platform agnostic but much simpler than Google Buffers.
SOAP with Fast Infoset is suited for small devices:
JAX-WS 2.0 and its reference implementation support both Fast Infoset and MTOM/XOP. This article includes information about Web Service Performance for Fast Infoset vs. MTOM/XOP:
http://www.devx.com/xml/Article/35385/1954
Fast Infoset is optimized for small
devices that have bandwidth
constraints, and is supported by many
vendors such as Microsoft .NET and
.NET CF, Sun GlassFish, BEA WebLogic,
IBM SDK for Java 6.0 and others.
http://en.wikipedia.org/wiki/Fast_Infoset

Is there a good HttpClient library for J2ME/MIDP?

I want to call some RESTful web services from a J2ME client running on a MIDP enabled mobile device. I read the MIDP api for HTTPConnections and thought this is just crying out for a simple wrapper to hide all those unpleasant byte arrays and such like. Before I write my own I wondered whether there was a good open source library already available.
-FE-
You might want to check out this little gem, Mobile Ajax for Java ME:
https://meapplicationdevelopers.java.net/mobileajax.html
One part is (from the site):
Asynchronous I/O for Java ME
This library provides the equivalent
of XmlHttpRequest for Java ME with
some additional functionality useful
for invoking RESTful web services.
It is layered on top of the
com.sun.me.web.path library. Features
include -
* Asynchronous versions of HTTP Get and Post
* HTTP Basic Authentication
* Multipart MIME (sender only)
* Progress listeners
LWUIT 1.5 now includes classes for accessing REST, using OAuth2, JSON, etc.
I don't know of any such library, but found some succinct examples of accessing various RESTful web services
We ended up writing our own simple wrapper api for a variety of reasons not the least of which was the fact that the Sony Ericsson K750 that we were developing for had a weird bug (that SE refused to fix) where if you tried to get/use a connection when the device was off network, more than about 20 times, the internal connection pool would get hosed and never recover unless you restarted the app.