users@glassfish.java.net

Re: any sample or tutorial about developing JAX-RS web services and clients?

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 12 Jan 2009 10:45:41 +0100

HI Sarah,

JAX-RS 1.0 only standardizes the server side.

Jersey provides a client API, see com.sun.jersey.api.client package:

   https://jersey.dev.java.net/source/browse/*checkout*/jersey/tags/jersey-1.0.1/api/jersey/com/sun/jersey/api/client/package-summary.html
   https://jersey.dev.java.net/source/browse/*checkout*/jersey/tags/jersey-1.0.1/api/jersey/index.html

The Jersey samples make use of the client API:

   http://download.java.net/maven/2/com/sun/jersey/samples/jersey-samples/1.0.1/jersey-samples-1.0.1-project.zip

For the particular sample in question (the hello world application)
look in the following sample zip:

   http://download.java.net/maven/2/com/sun/jersey/samples/helloworld/1.0.1/helloworld-1.0.1-project.zip

for the Java class MainTest.java for an example of how the Jersey
client API is utilized to invoke the resource.

You can of course paste the URL for the resource into a browser as
well, or use curl. For example:

   curl -v http://localhost:9998/helloworld

Paul.

On Jan 11, 2009, at 5:02 PM, Sarah kho wrote:

> Thank you for your links, What I couldnt find is a sanple client,
> imagine that I have
>
>
>
> @Path("/helloworld")
> public class HelloWorldResource {
>
> // The Java method will process HTTP GET requests
> @GET
> // The Java method will produce content identified by the MIME Media
> // type "text/plain"
> @Produces("text/plain")
> public String getClichedMessage() {
> // Return some cliched textual content
> return "Hello World";
> }
> }
>
>
> In my server, how does a client code for invoking this service looks
> like?
>
>
> thanks
>
> On Sun, Jan 11, 2009 at 5:08 PM, Felipe Gaścho <fgaucho_at_gmail.com>
> wrote:
> you may find useful info here:
>
> https://jersey.dev.java.net/
> http://java.sun.com/reference/blueprints/
>
> Btw, I am working in a rest web-services module in one of my open
> source projects.. anyone interested in joinning this learning effort,
> please register at footprint.dev.java.net
>
>
>
> On Sun, Jan 11, 2009 at 2:07 PM, Sarah kho <sarah.kho_at_gmail.com>
> wrote:
> > Hi
> >
> > I am looking to find some samples or tutorial which shows how I
> can develop
> > JAX-RS web services (restful web services) and restful web
> services clients.
> >
> > please let me know if you know any sample.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>