wood burning stoves 2.0*
The moose likes Web Services and the fly likes Help required: Compiling/Deploying a RESTful web service Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Web Services
Bookmark "Help required: Compiling/Deploying a RESTful web service" Watch "Help required: Compiling/Deploying a RESTful web service" New topic
Author

Help required: Compiling/Deploying a RESTful web service

aravind kanganar
Ranch Hand

Joined: Nov 08, 2009
Posts: 36
Hi all,

I am trying to write and run a RESTful WS.

I have jdk1.5,tomcat 5.5, JAX-WS2.1.7 jar(placed in lib directory of tomcat) and eclipse ganymede ide.

I wrote a sample AddNumbers service (got it from a web tutor) using elipse.I also created web.xml , sun-jaxws.xml and AddNums.wsdl and placed them all in WEB-INF directory of my project as directed in that tutorial.

Now the questions are:

The web.xml mentions a servlet "restful-addnumbers" , should it
be written by programmer or is it auto generated?

Do I need to use any other library or tool?

If I am going to write and deploy RESTful WS without an IDE, how to do so?



waiting for answers,

aravind




William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12791
    
    5
If you are using the Jersey (JSR-311) framework. You certainly do not need an IDE.

You just compile your service class(es) with the annotations and put them where Jersey can find them.

Bill
aravind kanganar
Ranch Hand

Joined: Nov 08, 2009
Posts: 36
hi,
Can I use jax-ws with jersey?

aravind
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
Just to clarify one thing:
JAX-WS is an API for creating web services; SOAP or XML, but not RESTful web services. The reference implementation is Metro.
JAX-RS is an API for creating RESTful web services. The reference implementation is Jersey.
Best wishes!
Leonardo Carreira
Ranch Hand

Joined: Apr 07, 2009
Posts: 489

Thanks Ivan for your explanation..
Which one between JAX-WS and JAX-RS that often used for developing Web Service?..
and what is the differences between JAX-WS and JAX-RS?..
Thanks in advance..

Sorry, perhaps my english language isn't too good.. Prepare for SCJP 6, Please God help me.. ☼
References : [Java.Boot] [JavaChamp] [JavaPrepare]
aravind kanganar
Ranch Hand

Joined: Nov 08, 2009
Posts: 36
Hi,

but check this site :http://java.sun.com/developer/technicalArticles/WebServices/restful/

It's mentioned there that jax-ws gives full support for the RESTful WS development.

Thanks and regards,
aravind
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
Well, if you want to be strict, you can implement a RESTful web service using socket streams.
Yes, you can do it with JAX-WS, but it feels slightly awkward to me when compared to using JAX-RS. An example can be found here: http://netbeans.org/kb/docs/websvc/rest.html
Best wishes!
aravind kanganar
Ranch Hand

Joined: Nov 08, 2009
Posts: 36
Thanks Ivan!
But can you clarify how jax-rs becomes better for RESTful programming...?
Don't mind I have very less knowledge about these.

-aravind
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
Leonardo Carreira wrote:Which one between JAX-WS and JAX-RS that often used for developing Web Service?..
and what is the differences between JAX-WS and JAX-RS?

The answer is: It depends.
It depends on what you want to do and, sometimes, it also depends on who you ask.
Here are some things that come to me in the spur of the moment:
Characteristics of RESTful web services are:
- Performs operations using a limited set of verbs (typically GET, PUT, POST, DELETE) on resources.
- Retrieves a representation of a resource using the JSON or XML data format.
- Uses URLs to address resources.
Example: http://my.server.com/resources/customer/12/orders/44
This URL would retrieve the customer 12's order 44.
- Always (?) uses HTTP transport.

Characteristics of SOAP web services:
- More choices; different transports (HTTP, JMS, TCP, you could even use mail), security (signature, encryption both whole and partial), can have attachments, can be compressed etc etc.
- With more choices also follows the chance of increased complexity.
- Interface and datatypes described by WSDL document.
- Uses operation names to address functionality.

My advice is: Play around with both RESTful and SOAP web services and get to know them. This way you will increase your chances of making the correct choice when you are to choose which one to use.
Best wishes!
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
aravind kanganar wrote:
But can you clarify how jax-rs becomes better for RESTful programming...?

Others have already said it much better than I am able to.
Take a look at this presentation of JAX-RS: http://wikis.sun.com/display/Jersey/Overview+of+JAX-RS+1.0+Features
Best wishes!
aravind kanganar
Ranch Hand

Joined: Nov 08, 2009
Posts: 36
ok
 
GeeCON Prague 2014
 
subject: Help required: Compiling/Deploying a RESTful web service