Deploy JAX-WS web services on Tomcat servlet container. Following steps of a web service deployment.
- Create a web service .
- Create a sun-jaxws.xml, defines web service implementation class.
- Create a standard web.xml, defines
WSServletContextListener
,WSServlet
and structure of a web project. - Build tool to generate WAR file.
- Copy JAX-WS dependencies to “${Tomcat}/lib” folder.
- Copy WAR to “${Tomcat}/webapp” folder.
- Start It.
HelloWorldService : End Point Interface
HelloWorldServiceImpl : Implementation Class
This method will return the string when you will create the client you can use this method
sun-jaxws.xml:
You need to create the this xml file to define the Name of the Web Service , implementation class to search the method in the class and url pattern to be used while calling the web service
<?xml version="1.0" encoding="UTF-8"?>
<endpoints
xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime"
version="2.0">
<endpoint
name="HelloWorldService"
implementation="com.javatopoint.blogspot.com.HelloWorldServiceImpl"
url-pattern="/helloService"/>
</endpoints>
Note: Implementation url will be depends your package name and implementation class name.
web.xml.
Insert Listener class in web.xml file
com.sun.xml.ws.transport.http.servlet.WSServletContextListener
and servlate class
com.sun.xml.ws.transport.http.servlet.WSServlet
JAX-WS Dependencies
By default, Tomcat does not comes with any JAX-WS dependencies, So, you have to include it manually.1. Go here http://jax-ws.java.net/.
2. Download JAX-WS RI distribution.
3. Unzip it and copy following JAX-WS dependencies to Tomcat library folder “{$TOMCAT}/lib“.
- jaxb-impl.jar
- jaxws-api.jar
- jaxws-rt.jar
- gmbal-api-only.jar
- management-api.jar
- stax-ex.jar
- streambuffer.jar
- policy.jar
Now Export your project to War file [ Right Click + Export + war ]
Put war file in tomcat webapps folder
Now Restart your Tomcat server you will find the folder with your web service name with all class and .java files.
You are all set to see that your webservice is deployed at tomcat
Go to browser and Enter the Url : localhost:Port_No/WAR_File_Name/Url_Pattern
When you click on the Url you will able to find the WSDL file.
No comments:
Post a Comment