The following outlines, at a high-level, what you must do to successfully deploy a Celtix Web service endpoint to a servlet container:
Build a WAR file that contains the your application, the WSDL file that defines your service, a web.xml deployment descriptor file that tells the servlet container to load the CXF servlet class, and a cxf-servlet.xml deployment descriptor file that configures the endpoints that plug into the CXF servlet.
Deploy the WAR file to your servlet container.
In order to deploy your application to a servlet container you must build a WAR file that has the following directories and files:
WEB-INF should include a:
cxf-servlet.xml file—which configures the endpoints that plug in to the CXF servlet. When the CXF servlet starts up, it reads the list of endpoint elements from this file and initializes a service endpoint for each one. See Example 2.1, “cxf-servlet.xml
file”
for more information.
web.xml file—which instructs the servlet container to load the org.apache.cxf.jaxws.servlet.CXFServlet class. An example of this file is contained in your directory.CeltixInstallDir/etc
WEB-INF/classes should include your Web service implementation class and any other classes (including the class hierarchy) generated by the Celtix wsdl2java utility.
WEB-INF/wsdl should include the WSDL file that defines the service that you are deploying.
The cxf-servlet.xml file configures the endpoints that plug into the CXF servlet. When the CXF servlet starts up it reads the list of endpoint elements in this file and initializes a service endpoint for each one.
Example 2.1, “cxf-servlet.xml
file”
shows the cxf-servlet.xml file used in the Celtix servlet container sample application. It contains one endpoint element that configures the Greeter service endpoint.
Example 2.1. cxf-servlet.xml file
<?xml version="1.0" encoding="UTF-8"?>
<endpoints>
name="hello_world"
interface="org.apache.hello_world_soap_http.Greeter"
implementation="demo.hw.server.GreeterImpl"
wsdl="WEB-INF/wsdl/hello_world.wsdl"
service="{http://apache.org/hello_world_soap_http}
SOAPService"
port="{http://apache.org/hello_world_soap_http}SOAPPort"
url-pattern="/hello_world" />
</endpoints>
You must include a web.xml deployment descriptor file that tells the application server to load the CXF servlet. Example 2.2, “web.xml deployment descriptor
file”
shows the that is used in the Celtix servlet container sample application. You do not need to change this file. A reference copy is located in directory.CeltixInstallDir/etc
Example 2.2. web.xml deployment descriptor file
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application
2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>cxf</display-name>
<description>cxf</description>
<servlet>
<servlet-name>cxf</servlet-name>
<display-name>cxf</display-name>
<description>Apache CXF Endpoint</description>
<servlet-class>org.apache.cxf.jaxws.servlet.
CXFServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>cxf</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>60</session-timeout>
</session-config>
</web-app>
How you deploy your WAR file depends on the servlet container that you are using. For example, to deploy your WAR file to Tomcat, copy it to the Tomcat CATALINA_HOME/server/webapp directory.
If you are using a different servlet container, please refer to the deployment documentation for that container.