Reputation: 4173
I'm studying web services using Java, and wondering if it's possible or not.
I've made a RESTful service client using a Java client Library, which is following REST's principles.
(To be more specific, I found this library on Github and am using it. This Java library interacts with CKAN, which is a sort of web-based open source data system)
Then, I wondered (am still wondering) if this REST client can work as a server for a SOAP web service, as this picture describes.
I tried it by creating a web service class within an EJB. I wrote almost the same code as the REST client into the EJB's web service class, so that the web service class would use the GET, POST and DELETE methods.
However, when I try to deploy this EJB (a SOAP web service), the Glassfish server indicates that...
Two web services are being deployed with the same endpoint URL ckan/ckan; The service that gets loaded last will always be the one that is active for this URL.
Exception while invoking class org.glassfish.ejb.startup.EjbDeployer load method
java.lang.RuntimeException: EJB Container initialization error
It might be just because I've already made a REST client which is using the same URL, but I haven't found the very reason.
Do you think, in SOAP web service, it is possible for the server side to have the standardized server methods (i.e. GET/POST/DELETE etc) in order to interact with an outside data repository (which is, in my case, CKAN ... a web-based data management system)?
Any insight will be appreciated.
PS
The purpose of using a REST client as a server of a SOAP is to test security issues of REST and SOAP and compare them. I don't think it is practical to use a REST client in such a way.
Upvotes: 1
Views: 683
Reputation: 979
If I understand your question correctly, for study (not practical) reasons, you want to have a REST web service invoke a SOAP web service (or vice versa). With some of the older libraries this was not possible because of design/code issues in the libraries. However, that is no longer true if you are using current versions of libraries.
Build a REST service with the API you want (spring libraries will do this nicely), and map the controller methods to the SOAP webservice you want to invoke (or vice versa). You're talking about a couple of controller classes with Spring annotations and some wrapper code and Java EE fluff.
If I understood the problem backwards, the answer is essentially the same - just exchange the SOAP and REST annotations.
Upvotes: 1
Reputation: 2136
YES - it can ..
I don't know what REST jar you are using - Please go for Apache CXF or Jersey 2 jars.
Have a single entry point for all REST Service - Using Apache CXF you can get a Front Servlet Architecture.
So your REST service will be deployed as
http://localhost:8080/**myRESTSERVICES**
Here Services will point it to a Servlet which will route the calls to underlying REST Service.
Here is the Web.xml Example :
<servlet>
<servlet-name>CXFServlet</servlet-name>
<display-name>CXF Servlet</display-name>
<servlet-class>
org.apache.cxf.transport.servlet.CXFServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>CXFServlet</servlet-name>
<url-pattern>/myRESTSERVICES</url-pattern>
</servlet-mapping
Here CXF Servlet acts as Front Servlet which will re-direct request to your underlying REST Web Services.
Now coming down to SOAP Web Services :
SOAP Service will run on different port as REST say : 9040 - or whatever you want it to be.
When SOAP will invoke it will call servlet on default HTTP Port which is 8080 in our case ( 9080 web sphere ) but port numbers are custome- u can configure it
Upvotes: 0