REST and Java ME
REST (Representational State Tranfer) is an architecture. Basically, it refers to the way the resources, commonly called URIs (Uniform Resource Identifier), are organized in the World Wide Web to be accessed and manipulated over the HTPP, using its default characteristics, like, for example, been stateless, specifying mime types, etc. The REST concept is not a new thing. Roy Fielding, one of the fathers of HTTP, has described it in his thesis.
Java people, lately, has started talking about RESTful Web Services after JSR 311. They, like other developers, were motivated by the fact that conventional Web Services (WS-*), that uses SOAP, WSDL, UDDI, whateverXYZ, can be heavy. Also, can be much heavier in a mobile! Just imagine you parsing a SOAP envelop that contains an encoded image and transfering (paying) all this overhead.
I have noticed two groups of REST developers: the ones who defend the use of the 4 HTPP methods (PUT, DELETE, GET, POST) and the others who prefer the browser way (GET, POST). I am not going to discuss this here (although I think the first way is more interesting), but in Java ME you will have problems with the first approach. The interface javax.microedition.io.HttpConnection, used by GCF (Generic Connection Framework), just allows GET, POST and HEAD. Urgghh?!
RESTful Web Services are usually consumed in JSON and/or XML. You can use both in Java ME, mixing together some interesting available solutions:
- Awesome project called Moble Ajax that contains a JSON parser (org.json.me), an expression language for it, streaming Atom implementation and an Asynchronous I/O with GET, POST and HTTP Basic Authentication.
- You can use JSR 280 or JSR 172 (available in MSA) for parsing the XML. Also, you can try the kXML 2 or some other solutions available in this old and still updated post.
That's it for today! Let's take a rest!
Have a nice week!
Bruno Ghisi
- Login or register to post comments
- Printer-friendly version
- brunogh's blog
- 1588 reads






Comments
by brunogh - 2008-09-07 16:47
Yes. It is an interesting idea and that project also provides the base.by guilherme_lopes - 2008-09-07 14:59
Mobile Ajax seems to be awesome. Did you test it? regardsby pedrobachiega - 2008-08-25 05:13
good approach for the subject bruno
thanks
by brunogh - 2008-08-14 06:45
Hello enrique, thanks for the comment! Looking for that article too!by eortiz - 2008-08-13 21:16
Bruno - MIDP3 includes all 5 HTTP methods (GET, HEAD, DELETE, PUT, POST), added specifically to support RESTful; I'm proud to say that was one of my contributions to MIDP3. Also, I have written an article on JSON on MIDP; that article should come up at the Sun mobility site maybe in a couple of weeks; keep an eye on that one. ceoby brunogh - 2008-08-13 11:25
Cheers!I forgot to mention, but there are other projects that makes HTTP connections. Usually, people has its own utility classes that deals with GCF too.
by terrencebarr - 2008-08-13 10:52
Bruno,Nice write-up. Thanks!
-- Terrence