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 Exposing a service as both Restful and  Soap Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Exposing a service as both Restful and  Soap " Watch "Exposing a service as both Restful and  Soap " New topic
Author

Exposing a service as both Restful and Soap

Cindy Jones
Ranch Hand

Joined: Oct 08, 2002
Posts: 66
I need to expose a functionality as a restful service as well as provide a SOAP interface.
I have implemented rest using JBOSS resteasy .
The rest service exposed is test which was implemented as below to support form and xml requests.


What is the best way to expose the test method as a SOAP service? I have implemented this as an Axis service by defining a method as below but is this the best approach?
Is there some functionality of rest easy that I can leverage to get this working?



Thanks in advance!
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
The simplest way is to use a Java-first approach according to, for instance, the following tutorial: http://www.netbeans.org/kb/docs/websvc/jax-ws.html
You should pay attention to separate things related to the different services in one layer, the service layer, and common request processing code in another layer, the processing layer.
I suspect it will mean more work to reuse part(s) from the REST service in the SOAP service. The only candidate(s) I can think of would be JAXB bean classes.
When doing Java-first SOAP web service development, artifacts will be generated at deploy time, so you may never see them. The container will take care of these things for you, so I don't think there is anything to gain from writing it yourself, and thus no need to try to use RESTEasy when implementing the SOAP web service.
Hope this helps and best wishes!
Cindy Jones
Ranch Hand

Joined: Oct 08, 2002
Posts: 66
How about using Apache CXF? Someone recommended this as an alternate solution.
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi again!
Yes, Apache CXF can do both REST and SOAP web services. I have used it to write REST web services and liked it.
Best wishes!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exposing a service as both Restful and Soap
 
Similar Threads
Using restful client which auto map objects into xml
Tomcat 7 throwing "A message body reader for... is not found"
Error 405 with HttpUrlConnection when request web service
Exposing Methods as RESTFul Services
Problem with JERSEY and JAX-RS