LibraryLink ToToggle FramesPrintFeedback

Using the CXF Servlet

FUSE Services Framework provides a standard servlet, the CXF servlet, which acts as an adapter for the Web service endpoints. The CXF servlet is the easiest method for deploying Web services into a servlet container.

Figure 6.1 shows the main components of a FUSE Services Framework endpoint deployed using the CXF servlet.


  • Deployed WAR file — Service providers are deployed to the servlet container in a Web Archive (WAR) file. The deployed WAR file contains:

    • the compiled code for the service provider being deployed

    • the WSDL file defining the service

    • the FUSE Services Framework configuration file

      This file, called cxf-servlet.xml, is standard FUSE Services Framework configuration file that defines all of the endpoints contained in the WAR.

    • the Web application deployment descriptor

      All FUSE Services Framework Web applications using the standard CXF servlet need to load the org.apache.cxf.transport.servlet.CXFServlet class.

  • CXF servlet — The CXF servlet is a standard servlet provided by FUSE Services Framework. It acts as an adapter for Web service endpoints and is part of the FUSE Services Framework runtime. The CXF servlet is implemented by the org.apache.cxf.transport.servlet.CXFServlet class.

To deploy a FUSE Services Framework endpoint to a servlet container you must:

  1. Build a WAR that contains your application and all the required support files.

  2. Deploy the WAR file to your servlet container.

To deploy your application to a servlet container, you must build a WAR file. The WAR file's WEB-INF folder should include the following:

The cxf-servlet.xml file is a FUSE Services Framework configuration file that configures the endpoints that plug into the CXF servlet. When the CXF servlet starts up it reads the jaxws:endpoint elements in this file and initializes a service endpoint for each one.

Example 6.1 shows a simple cxf-servlet.xml file.

Example 6.1. CXF Servlet Configuration File

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" 1
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance
       xmlns:jaxws="http://cxf.apache.org/jaxws"
       xmlns:soap="http://cxf.apache.org/bindings/soap"
       xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://cxf.apache.org/bindings/soap http://cxf.apache.org/schemas/configuration/soap.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
    <jaxws:endpoint 2
        id="hello_world"
        implementor="demo.hw.server.GreeterImpl"
        wsdlLocation="WEB-INF/wsdl/hello_world.wsdl"
        address="/hello_world">
             <jaxws:features>
                  <bean class="org.apache.cxf.feature.LoggingFeature"/>
             </jaxws:features>
    </jaxws:endpoint>
</beans>

The code shown in Example 6.1 is explained as follows:

1

The Spring beans element is required at the beginning of every FUSE Services Framework configuration file. It is the only Spring element that you need to be familiar with.

2

The jaxws:endpoint element defines a service provider endpoint. The jaxws:endpoint element has the following attributes:

  • id — Sets the endpoint id.

  • implementor — Specifies the class implementing the service.

    [Important]Important

    This class needs to be included in the WAR's WEB-INF/classes folder.

  • wsdlLocation — Specifies the WSDL file that contains the service definition.

    [Important]Important

    The WSDL file location is relative to the WAR's WEB-INF/wsdl folder.

  • address — Specifies the address of the endpoint as defined in the service's WSDL file that defines service that is being deployed.

  • jaxws:features — Defines features that can be added to your endpoint.

For more information on configuring a jaxws:endpoint element, see Using the jaxws:endpoint Element.

You must include a web.xml deployment descriptor file that instructs the servlet container to load the CXF servlet. Example 6.2 shows a web.xml file. It is not necessary to change this file. A reference copy is located in the InstallDir/etc directory.


How you deploy your WAR file depends on the servlet container that you are using. For example, to deploy your WAR file to Tomcat, you copy it to the Tomcat CATALINA_HOME/server/webapp directory.