Fuse 6 is no longer supported
As of February 2025, Red Hat Fuse 6 is no longer supported. If you are using Fuse 6, please upgrade to Red Hat build of Apache Camel.Ce contenu n'est pas disponible dans la langue sélectionnée.
Chapter 6. Deploying an Apache Camel WS Endpoint
Abstract
6.1. Apache Camel CXF Example Copier lienLien copié sur presse-papiers!
Overview Copier lienLien copié sur presse-papiers!
url-pattern
setting from web.xml
, and the URI of the Camel CXF endpoint are combined to give the URL, http://localhost:8080/camel-example-cxf-tomcat/webservices/incident
.
Figure 6.1. Camel CXF Example Deployed in a Web Server
camel-example-cxf-tomcat example Copier lienLien copié sur presse-papiers!
examples/camel-example-cxf-tomcat
directory. For details of how to install the Apache Camel distribution, see the section called “Install Apache Camel”.
Camel CXF component Copier lienLien copié sur presse-papiers!
Exchange
object, and can then propagate through the route.
cxf:Address[?Options]
- Specifies the WSDL endpoint address and a (potentially large) number of options to configure the endpoint.
cxf:bean:BeanID[?Options]
- References a bean with the ID,
BeanID
, defined using thecxf:cxfEndpoint
element (where thecxf
prefix is bound to thehttp://camel.apache.org/schema/cxf
namespace). The advantage of this approach is that all of the configuration complexity is encapsulated in the bean. Typically, this means that very few options (or none) need to be specified on the endpoint URI.NoteThecxf:cxfEndpoint
element, which binds a WS endpoint to a Camel route, should not be confused with thejaxws:endpoint
element, which binds a WS endpoint directly to a Java class.
More about the Camel CXF component Copier lienLien copié sur presse-papiers!
- Web Services and Routing with Camel CXF
- The CXF chapter from the EIP Component Reference.
web.xml file Copier lienLien copié sur presse-papiers!
web.xml
file. In the camel-example-cxf-tomcat
project, the web.xml
file is stored at the following location:
camel-example-cxf-tomcat/src/main/webapp/WEB-INF/web.xml
camel-example-cxf-tomcat/src/main/webapp/WEB-INF/web.xml
web.xml
file.
Example 6.1. web.xml File for the camel-example-cxf-tomcat Example
web.xml
file are:
servlet/servlet-class
- Specifies the
org.apache.cxf.transport.servlet.CXFServlet
class, which implements a special servlet that enables you to deploy Apache CXF WS endpoints. servlet-mapping/url-pattern
- Determines which URLs are routed to this servlet. In general, the servlet URL has the following form:
http://Host:Port/WARFileName/URLPattern
http://Host:Port/WARFileName/URLPattern
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Where the base URL,http://Host:Port
, is determined by the configuration of the Web server, theWARFileName
is the root of theWARFileName.war
WAR file, and theURLPattern
is specified by the contents of theurl-pattern
element.Assuming that the Web server port is set to 8080, thecamel-example-cxf-tomcat
example servlet will match URLs of the following form:http://localhost:8080/camel-example-cxf-tomcat/webservices/*
http://localhost:8080/camel-example-cxf-tomcat/webservices/*
Copy to Clipboard Copied! Toggle word wrap Toggle overflow listener/listener-class
- This element launches a Spring container.
context-param
- This element specifies the location of the Spring XML file,
camel-config.xml
, in the WAR. The Spring container will read this parameter and load the specified Spring XML file, which contains the definition of the Camel route.
listener-class
element here, because the CXFServlet
class already creates its own Spring container. If you put the Spring XML file in the location expected by the CXFServlet
class (that is, WEB-INF/cxf-servlet.xml
) instead of the location used by this example (that is, WEB-INF/classes/camel-config.xml
), you could remove the Spring container settings from this web.xml
file.
Spring XML file Copier lienLien copié sur presse-papiers!
camel-config.xml
, contains the following XML code:
RouteBuilder
class is defined in the Java class, org.apache.camel.example.cxf.CamelRoute
.
Camel route class Copier lienLien copié sur presse-papiers!
Example 6.2. Route Definitions in the CamelRoute Class
from(uri)
DSL command). The Camel CXF endpoint is defined using the following endpoint URI:
cxf:/incident?serviceClass=org.apache.camel.example.cxf.incident.IncidentService
cxf:/incident?serviceClass=org.apache.camel.example.cxf.incident.IncidentService
IncidentService
class in this URI. The relative path, /incident
, defines the tail of the servlet URL for this Web service. Hence, the full servlet URL for the Web service is the following:
http://localhost:8080/camel-example-cxf-tomcat/webservices/incident
http://localhost:8080/camel-example-cxf-tomcat/webservices/incident
serviceClass
option specifies the name of the Service Endpoint Interface (SEI) for this Web service. By default, the CXF endpoint is set up to use the POJO mode, using the SEI to check the syntax of incoming messages.