LibraryToggle FramesPrintFeedback

The Camel CXF Proxy Demonstration

Overview

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 Apache Camel, the Camel CXF proxy demonstration. Figure 6 gives an overview of how this demonstration works

Figure 6. Camel CXF Proxy Overview

Camel CXF Proxy Overview

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 Apache Camel route performs some processing on the WSDL message (using the enrichBean) before forwarding it to the real Web service.

Modifications

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:

  1. SSL/TLS security is enabled on the connection between the WS client and the Camel CXF endpoint.

  2. The Apache Camel route and the RealWebServiceBean bean are both deployed into the OSGi container.

Obtaining the demonstration code

The Camel CXF proxy demonstration is available only from the standalone distribution of Apache Camel. Download version 2.10.0.fuse-71-047 of Apache Camel from the download page, http://fusesource.com/downloads/, and install it according to the instructions in the Installation Guide.

Assuming that you have installed Apache Camel in CamelInstallDir, you can find the Camel CXF proxy demonstration in the following directory:

CamelInstallDir/examples/camel-example-cxf-proxy

Physical part of the WSDL contract

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 19.

Example 19. 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]Note

The address URL appearing in the WSDL contract (the value of the soap:address element's location attribute) is not important here, because the application code overrides the default value of the address URL.

WSDL addressing details

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]Note

The preceding address is specified when the reportIncident bean is created using a cxf: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]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.

Comments powered by Disqus