Library Link To Toggle Frames Print Feedback

Servlet Container Demonstration

The servlet container demonstration shows how to deploy a service into a standard Web server, using a CXF servlet that acts as an adapter for Web services.

Demonstration location

The servlet container demonstration is located in the following directory:

CeltixInstallDir/samples/service_creation/hello_world

Demonstration overview

Figure 3.1, “Overview of the Servlet Container Demonstration” shows the main components of the servlet container demonstration.

Figure 3.1. Overview of the Servlet Container Demonstration

Overview of the Servlet Container Demonstration

Web server

The Web server shown in Figure 3.1, “Overview of the Servlet Container Demonstration” can be any Web server that is capable of acting as a servlet container—for example, Apache Tomcat. When a Web server is used as the container, all of the hosted services are accessed through the same IP port. For example, the default IP port for Tomcat is 8080, which gives a base URL of http://Hostname:8080.

Deployed WAR file

The Greeter service is deployed to the Web server as a Web archive (WAR) file. In addition to configuration files, the WAR file contains the compiled code for the Greeter service, the WSDL stub code, and a copy of the WSDL contract. For more details about the WAR file, see Deploying to a Servlet Container .

CXF servlet

The CXF servlet is a standard servlet provided by Celtix ASE that acts as an adapter for Web service endpoints. Each instance of a CXF servlet can host single or multiple service endpoints (see cxf-servlet.xml file ). The CXF servlet is part of the Celtix ASE runtime and is implemented by the org.apache.cxf.jaxws.servlet.CXFServlet class.

The CXFServlet class is referenced, but not included in the WAR file. There is no need to include it, because the Web server can extract the CXFServlet class from the Celtix ASE runtime.

Celtix ASE runtime

The Celtix ASE runtime Jars must be accessible to the deployed service. Normally, you would need to perform specific steps to install the Celtix ASE runtime in the Web server. In the case of the Web server bundled with Celtix, however, these steps are performed automatically by the Celtix installer at install time.

Greeter service

The application code for the Greeter service is identical to the case of a standalone service—see Greeter Service Implementation . The code is not affected by being deployed into a servlet container.

Although the SOAP binding continues to be used to encode messages, the HTTP port specified in the original WSDL contract is irrelevant in this scenario. The HTTP protocol layer is now implemented by the Web server, not the Celtix ASE runtime.

WSDL contract

The original WSDL contract for the service is included in the WAR file. This static copy of the WSDL contract specifies the binding for the Greeter service. The port address in the WSDL contract is ignored, however.

When the Greeter service is initialized by the servlet container, Celtix automatically updates the in-memory copy of the WSDL contract with the correct endpoint address. It is this updated copy of the contract that is sent to clients that query the WSDL contract.