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.Questo contenuto non è disponibile nella lingua selezionata.
35.4. Instantiate the WS Endpoint
Overview Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
In Apache CXF, you create a WS endpoint by defining a
jaxws:endpoint
element in XML. The WS endpoint is effectively the runtime representation of the Web service: it opens an IP port to listen for SOAP/HTTP requests, is responsible for marshalling and unmarshalling messages (making use of the generated Java stub code), and routes incoming requests to the relevant methods on the implementor class.
In other words, creating a Web service in Spring XML consists essentially of the following two steps:
- Create an instance of the implementor class, using the Spring
bean
element. - Create a WS endpoint, using the
jaxws:endpoint
element.
The jaxws:endpoint element Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
You can instantiate a WS endpoint using the
jaxws:endpoint
element in a Spring file, where the jaxws:
prefix is associated with the http://cxf.apache.org/jaxws
namespace.
Note
Take care not to confuse the
jaxws:endpoint
element with the cxf:cxfEndpoint
element, which you meet later in this guide: the jaxws:endpoint
element is used to integrate a WS endpoint with a Java implementation class; whereas the cxf:cxfEndpoint
is used to integrate a WS endpoint with a Camel route.
Define JAX-WS endpoint in XML Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
The following sample Spring file shows how to define a JAX-WS endpoint in XML, using the
jaxws:endpoint
element.
Address for the Jetty container Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
Apache CXF deploys the WS endpoint into a Jetty servlet container instance and the
address
attribute of jaxws:endpoint
is therefore used to configure the addressing information for the endpoint in the Jetty container.
Apache CXF supports the notion of a default servlet container instance. The way the default servlet container is initialized and configured depends on the particular mode of deployment that you choose. For example the Red Hat JBoss Fuse container and Web containers (such as Tomcat) provide a default servlet container.
There are two different syntaxes you can use for the endpoint address, where the syntax that you use effectively determines whether or not the endpoint is deployed into the default servlet container, as follows:
- Address syntax for default servlet container—to use the default servlet container, specify only the servlet context for this endpoint. Do not specify the protocol, host, and IP port in the address. For example, to deploy the endpoint to the
/Customers
servlet context in the default servlet container:address="/Customers"
address="/Customers"
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Address syntax for custom servlet container—to instantiate a custom Jetty container for the endpoint, specify a complete HTTP URL, including the host and IP port (the value of the IP port effectively identifies the target Jetty container). Typically, for a Jetty container, you specify the host as
0.0.0.0
, which is interpreted as a wildcard that matches every IP network interface on the local machine (that is, if deployed on a multi-homed host, Jetty opens a listening port on every network card). For example, to deploy the endpoint to the custom Jetty container listening on IP port,8083
:address="http://0.0.0.0:8083/Customers"
address="http://0.0.0.0:8083/Customers"
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteIf you want to configure a secure endpoint (secured by SSL), you would specify thehttps:
scheme in the address.
Referencing the service implementation Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
The
implementor
attribute of the jaxws:endpoint
element references the implementation of the WS service. The value of this attribute can either be the name of the implementation class or (as in this example) a bean reference in the format, #BeanID
, where the #
character indicates that the following identifier is the name of a bean in the bean registry.