Skip to main content

REST and Java ME

Posted by brunogh on August 12, 2008 at 8:45 PM PDT

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, 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 (, 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

Related Topics >>


Yes. It is an interesting idea and that project also provides the base.

Mobile Ajax seems to be awesome. Did you test it? regards

good approach for the subject bruno


Hello enrique, thanks for the comment! Looking for that article too!

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. ceo

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.


Nice write-up. Thanks!

-- Terrence