Re: Does it matter how you implement RESTful web services?
On Thu, 29 Apr 2010, ses wrote:
Just a general open ended question - I quite familiar with SOAP / WSDL
based web services and implementing them in Java (JAX-WS), but I've not
much experience of RESTful web services. As it is basically just a
design rather than a standard, are there any issues in terms of how you
implement them (for consumption by your own applications)?
Currently I'm considering just implementing them by simply writing a
simple HTTP server, and consuming them using a HTTP request which are
both very easy to do in java
I'd usually be thinking in terms of writing a servlet (or even a JSP)
rather than a server, and running it inside a servlet container.
If you don't want the overhead of a servlet container, you should look
into embedding Jetty:
http://wiki.eclipse.org/Jetty/Tutorial/Embedding_Jetty
If you want even more lightweight (but not very scalable, AFAIK), Sun's
super-secret embedded webserver is already in your JDK (as long as you
have a Sun 1.6 JDK):
http://java.sun.com/javase/6/docs/jre/api/net/httpserver/spec/index.html
Either way, writing an HTTP server from scratch is a mad idea. Perhaps
that's not what you meant.
On the client side, writing your own HTTP client is marginally less
unreasonable, but still pretty silly given the existence of the JDK;s
HttpURLConnection and Apache's HttpClient:
http://hc.apache.org/
tom
--
Formal logical proofs, and therefore programs - formal logical proofs
that particular computations are possible, expressed in a formal system
called a programming language - are utterly meaningless. To write a
computer program you have to come to terms with this, to accept that
whatever you might want the program to mean, the machine will blindly
follow its meaningless rules and come to some meaningless conclusion. --
Dehnadi and Bornat