...
Expose the Web Service as a Servlet in web.xml
- In Project Explorer view, double-click on jaxws-converter --> WebContent --> WEB-INF --> web.xml to open it in an editor and add the following <servlet> and <servlet-mapping> elements inside it.
Code Block xml xml <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> <display-name>jaxws-converter</display-name> <servlet> <display-name>Converter</display-name> <servlet-name>Converter</servlet-name> <servlet-class> org.apache.geronimo.samples.jaxws.ConverterService </servlet-class> </servlet> <servlet-mapping> <servlet-name>Converter</servlet-name> <url-pattern>/converter</url-pattern> </servlet-mapping> </web-app>
Deploy the Web Service
- In Servers view, right-click on Apache Geronimo Server Runtime and select Add and Remove Projects.
- In the popup dialog, select jaxws-converter project, click Add, and then click Finish. Start the Geronimo server if it is not already running. The Web Service will now be deployed, and Geronimo will create the required WSDL and other required artifacts.
- Once the Web Service is deployed on to the server (Server Status says Synchronized), launch a browser and go to the following url:
http://localhost:8080/jaxws-converter/converter.
You should see a message from Axis2 engine as below:
- You can also view the WSDL file generated by Geronimo by going to the following url:
http://localhost:8080/jaxws-converter/converter?wsdlInfo title Generated files by Geronimo Geronimo processes the annotations in source files and automatically generates the required artifacts to deploy the Web Service.
You can see the Geronimo created files in the directory <INSTALL_DIR>/repository/org/apache/geronimo/samples/jaxws/jaxws-converter/1.0/jaxws-converter-1.0.car/. At this location you can find a new directory which Geronimo created for deploying the web service which contains the WSDL file and other required stubs.
Tip | ||
---|---|---|
| ||
Geronimo has a built-in plug-in named jaxws-tools which provides tools for generating WSDL and other necessary files used in JAX-WS web services. The plug-in relies on Sun's wsgen and wsimport tools to generate the web services artifacts. Please see wsgen or wsimport documentation for more information. |
Test the Web Service using Eclipse Web Services Explorer
- From Eclipse's main menu, click Run --> Launch the Web Services Explorer.
- The Web Services Explorer will open up as shown below:
- On the top right corner of this explorer, click on the icon for WSDL Page. Under the Navigation frame, you will now see WSDL Main (instead of UDDI Main). Click that WSDL Main link and the Actions frame will show a form as below:
- Enter the URL of your WSDL document i.e http://localhost:8080/jaxws-converter/converter?wsdl in the form and click Go. Now you can see the methods that are exposed by your Web Service.
- Clicking on any method will take you to a form asking for input parameters. If you don't see any field to enter input arguments click Add.
- Enter the input arguments and click Go. You can see the output of the Web Service in the Status frame at the bottom.
This completes the process of deploying the web service to Geronimo and testing it. You can also refer to the following tutorial to develop a actual client for a web service that is already deployed on Geronimo Developing Client Applications for a JAX-WS Web Service.