Does it matter how you implement RESTful web services?

S

ses

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
 
M

Mike Schilling

ses said:
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

Look into Jersewy (Sun's implementation of JAX-RS.) It's very productive,
as it lets annotations do much of the work of defining the service and
operations, and how the different parts of the logical message are mapped
into the parts of the physical HTTP message.
 
S

ses

Thanks for the information, this Jersey API certainly seems useful. It
still leaves me wondering if it is more appropriate in a lot of cases
to write one's own web service using HTTP. As RESTful web services
tend to be a lightweight thing it seems that perhaps it is better to
have a hands-on approach to implementing it.

Other than making it easier to code and to map the data in the HTTP
requests/responses, what else does the Jersey API offer in terms of
reliability, scalability etc. versus an ordinary HTTP server
implementation in Java?
 
M

Mike Schilling

ses said:
Other than making it easier to code and to map the data in the HTTP
requests/responses, what else does the Jersey API offer in terms of
reliability, scalability etc. versus an ordinary HTTP server
implementation in Java?

AFAIK, nothing, any more than using JAXB gives you scalability and
reliability over coding the XML-parsing yourself.
 
T

Tom Anderson

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
 
S

ses

Yes, sorry I wasn't very clear, I was meaning to use Java's HTTP
server. A servlet is something I hadn't considered but seems like a
good solution too.

I've already experimented with writing HTTP clients for RESTful web
services using the Java Socket implementation, which seems to work
well. I know it is a little odd but I somehow prefer the feeling of
knowing what's going on a bit more when it comes to working with HTTP
which is a relatively low-level thing to do anyway.

Thanks for the input though, RESTful web services is fairly new to me
and I wanted to check there wasn't any one 'right' way to do it that I
was missing.
 
L

Lew

ses said:
Yes, sorry I wasn't very clear, I was meaning to use Java's HTTP
server. A servlet is something I hadn't considered but seems like a
good solution too.

Please do not top-post.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,017
Latest member
GreenAcreCBDGummiesReview

Latest Threads

Top