File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes JAX-WS and REST, anyone? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Web Services
Bookmark "JAX-WS and REST, anyone?" Watch "JAX-WS and REST, anyone?" New topic
Author

JAX-WS and REST, anyone?

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42030
    
  64
Trying to simplify the WS infrastructure, I'm playing with JAX-WS for implementing REStful WS. The client side is easy enough, but it seems that the server-side isn't widely explored (or at the least not publicly written about). In particular, I'm looking for a way to have a URL like

automatically routed to a method that's declared to handle the operation "doTheRestThing", and pass the parameters "ulf" and "42" to it. Mapping the operation is the easy part, but how are parameters handled? Does anyone have an example? Is this really as simple as it gets?


Ping & DNS - my free Android networking tools app
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12791
    
    5
I did some playing around with the service end of REST. Rather than mapping the request to a method, I mapped the request to a class - using an XML configuration file. Each class had its own doGet( request, response ) so taking apart the parameters was delegated to the class.

After much wheel-spin with class loaders I got it to where I could add a new class to the configuration without restarting the server thus making the debug cycle much faster.

Bill
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
Well, for comparison sake this is the beginning of a Restlet version.



I wouldn't be surprised if the JAX-WS REST support will vanish in future versions if JSR 311: JAX-RS: The Java� API for RESTful Web Services goes anywhere.
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
FYI: Currently wadl2java only supports client side stubs. So for interest sake I whipped together a WADL:



and generated the code


This resulted in four files: package-info.java, UserDetailsType.java, ObjectFactory.java and Endpoint.java
package-info.java

UserDetailsType.java


ObjectFactory.java

Endpoint.java

I think things may become a bit clearer once wadl2java supports the generation of server-side skeletons - however the handling of the link elements in the WADL could prove interesting.

[ UD: added a few linebreaks to preserve the layout ]
[ November 26, 2007: Message edited by: Ulf Dittmer ]
 
GeeCON Prague 2014
 
subject: JAX-WS and REST, anyone?