In order to explain how to secure a Camel CXF endpoint in OSGi, this tutorial builds on an example available from the standalone distribution of Fuse Mediation Router, the Camel CXF proxy demonstration. Figure 7.1 gives an overview of how this demonstration works
The report incident Web service, which is implemented by the
RealWebServiceBean
, receives details of an incident (for example, a
traffic accident) and returns a tracking code to the client. Instead of sending its
requests directly to the real Web service, however, the WS client connects to a
Camel CXF endpoint, which is interposed between the WS client and the real Web
service. The Fuse Mediation Router route performs some processing on the WSDL message (using the
enrichBean
) before forwarding it to the real Web service.
In order to demonstrate how to enable SSL/TLS on a Camel CXF endpoint in the context of OSGi, this chapter contains instructions on how to modify the basic demonstration as follows:
SSL/TLS security is enabled on the connection between the WS client and the Camel CXF endpoint.
The Fuse Mediation Router route and the
RealWebServiceBean
bean are both deployed into the OSGi container.
The Camel CXF proxy demonstration is available only from the standalone distribution of Fuse Mediation Router. Download version 2.8.0-fuse-00-08 of Fuse Mediation Router from the ESB download page, http://fusesource.com/downloads/, and install it according to the instructions in the Installation Guide.
Assuming that you have installed Fuse Mediation Router in
CamelInstallDir
, you can find the Camel CXF proxy
demonstration in the following directory:
CamelInstallDir
/examples/camel-example-cxf-proxy
The physical part of the WSDL contract refers to the wsdl:service
and
wsdl:port
elements. These elements specify the transport details
that are needed to connect to a specific Web services endpoint. For the purposes of
this demonstration, this is the most interesting part of the contract and it is
shown in Example 7.1.
Example 7.1. The ReportIncidentEndpointService WSDL Service
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
...
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
targetNamespace="http://reportincident.example.camel.apache.org">
...
<!-- Service definition -->
<wsdl:service name="ReportIncidentEndpointService">
<wsdl:port name="ReportIncidentEndpoint" binding="tns:ReportIncidentBinding">
<soap:address location="http://localhost:9080/camel-example-cxf-proxy/webservices/incident"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
![]() | Note |
---|---|
The address URL appearing in the WSDL contract (the value of the
|
A WS client needs three pieces of information to connect to a WSDL service: the WSDL service name, the WSDL port name, and the address URL of the Web service. The following addressing details are used to connect to the proxy Web service and to the real Web service in this example:
- WSDL service name
The full QName of the WSDL service is as follows:
{http://reportincident.example.camel.apache.org}ReportIncidentEndpointService
- WSDL port name
The full QName of the WSDL port is as follows:
{http://reportincident.example.camel.apache.org}ReportIncidentEndpoint
- Address URL
The address URL of the proxy Web service endpoint (which uses the HTTPS protocol) is as follows:
https://localhost:9080/camel-example-cxf-proxy/webservices/incident
Note The preceding address is specified when the
reportIncident
bean is created using acxf:cxfEndpoint
element in the bundle's Spring configuration file,src/main/resources/META-INF/spring/camel-config.xml
.The address URL of the real Web service endpoint (using the HTTP protocol) is as follows:
http://localhost:9081/real-webservice
Note The preceding address is specified when the
realWebService
bean is created in the bundle's Spring configuration file,src/main/resources/META-INF/spring/camel-config.xml
.