Part 1 – Establishing a Simple Camel Route
Overview
For the last few days I have been getting to grips with JBoss Openshift, which is JBoss’ answer to PAAS – Platform as a Service.
Like all relatively new technologies (after all this kind of thing has only been around for about 10 years) there is a lack of good, working examples. My ultimate objective is to provide Web Service end points to a rule engine that analyzes Stock Market data and identifies stocks and shares that satisfy my own criteria for investment. These will then be reported back to myself for further, manual, consideration.
For now, my immediate challenge is to get Web Services exposed that integrate with Apache Camel on JBoss EAP.
Of the limited amount of information and examples that are available on the internet to work with OpenShift, I have recently encountered a set of videos put together byChristian Posta that are superb.
This blog is heavily based on one of Christian’s videos. It is not an attempt to steal his good work, but rather to add my own personal notes, to his work and then adapt the material to work with OpenShift.
I will also detail some of the problems I encountered and overcame en route.
Download and install JBoss Developer Studio
- Download JBoss Developer Studio from http://www.jboss.org/products
- JBoss will require you to login, or register for free and then login.
- This will download a jar file.
- Once the file has downloaded, double-click it to install JBoss Developer Studio
- accept the license agreement
- go with defaults all the way
- Include Red Hat JBoss Enterprise Application Platform (EAP) – this is the default
- Allow Developer Studio to start up
- Use the default workspace
JBoss Developer Studio will now be up and running
Install JBoss Tools Integration Stack
- Open JBoss Developer Studio
- Click on JBoss Central
- Click on Software Update
- Check JBoss Integration and SOA Development
- Click Install
- Select All when prompted for the items you wish to install
- Click Next
- Accept the License Agreement
- Click Finish
- After installation, you will need to restart JBoss Developer Studio

Create New Fuse Project
- Right Click in Project Explorer
- New -> Fuse Project
- Use Default Workspace
- Next
- Select io.fabric8 :: camel-dxf-contract-first-archetype – this is the default
- Group Id: com.skills421
- Artifact Id: camel-cxf-contract-first
- click Finish

This will take a while to create and build as it downloads all the maven dependencies.
Looking around our Fuse Project
The Camel Routes
- Expand the project
- Expand Camel Contexts
- Double click src/main/resources/META-INF

- Camel Route starts with a cxf endpoint
- routes the message to a SEDA Queue – an in-memory asynchronous queue
- Transforms the message into a constant – “OK”
The SEDA Queue has a listener defined to handle the messages

- This is defined in a second Camel Route
- The queue just listens, and
- sends the message to a mock
Fixing the WSDL
- expand src/main/resources
- expand the wsdl folder
- double click order.wsdl
- click on the source tab to see the xml representation
Note that the soap:body contains a parts attribute. This occurs twice in the wsdl file.
Delete both parts attributes to give:
<?xml version="1.0" encoding="ISO-8859-1"?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://order.camelinaction" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://order.camelinaction"> <!-- Type definitions for input- and output parameters for webservice --> <wsdl:types> <xs:schema targetNamespace="http://order.camelinaction"> <xs:element type="xs:string" name="partName" /> <xs:element type="xs:int" name="amount" /> <xs:element type="xs:string" name="customerName" /> <xs:element type="xs:string" name="resultCode" /> </xs:schema> </wsdl:types> <!-- Message definitions for input and output --> <wsdl:message name="purchaseOrder"> <wsdl:part name="partName" element="tns:partName" /> <wsdl:part name="amount" element="tns:amount"/> <wsdl:part name="customerName" element="tns:customerName"/> </wsdl:message> <wsdl:message name="orderResult"> <wsdl:part name="resultCode" element="tns:resultCode" /> </wsdl:message> <!-- Port (interface) definitions --> <wsdl:portType name="OrderEndpoint"> <wsdl:operation name="order"> <wsdl:input message="tns:purchaseOrder" /> <wsdl:output message="tns:orderResult" /> </wsdl:operation> </wsdl:portType> <!-- Port bindings to transports and encoding - HTTP, document literal encoding is used --> <wsdl:binding name="OrderBinding" type="tns:OrderEndpoint"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http" /> <wsdl:operation name="order"> <soap:operation soapAction="http://order.camelinaction/Order" style="document" /> <wsdl:input> <soap:body use="literal" /> </wsdl:input> <wsdl:output> <soap:body use="literal" /> </wsdl:output> </wsdl:operation> </wsdl:binding> <!-- Service definition --> <wsdl:service name="OrderEndpointService"> <wsdl:port name="OrderService" binding="tns:OrderBinding"> <soap:address location="http://localhost:9000/order" /> </wsdl:port> </wsdl:service> </wsdl:definitions>
Running the Camel Routes
- right click src/main/resources/META-INF
- Run As -> 3 Local Camel Context (without tests)
This may take a short while to run the first time as is downloads resources

If we now check the log once the server has started and we can see that the service end point is set to: http://localhost:9000/order/
If we open a browser and navigate to http://localhost:9000/order/?wsdl we can see the wsdl file that is being exposed from the Camel route.

If we click on the Design tab for camel-cxf.xml, and click on the endpoint in the diagram; the properties tab will show that the Uri for the endpoint is: cxf:bean:orderEndpoint

Now if we look at camel-cxf.xml, we can see the classes, address to publish to, and what wsdl to use.

Sending a Message to the Endpoint
To do this we are going to send a mock message using SoapUI. Before we can do this, we must first download and install SoapUI.
Download and Install SoapUI
- Download SoapUI installer from http://sourceforge.net/projects/soapui/files/
- Run the installer, accept the license agreement and go with all the defaults
- Launch SoapUI once the installation has finished
Send a Soap Message
- Launch SoapUI
- Right click on Projects -> New Soap Project
- Project Name: OrderDemo
- Initial WSDL: http://localhost:9000/order/?wsdl
- Check Create Requests

- In SoapUI expand order
- Double click Request 1
- In the xml, populate partName, amount, and customerName
- click on the green triangular send button
- look for OK being returned in the response window

[…] This post follows on from EAP Webservice with Camel on Openshift – part 1 […]
[…] EAP Webservice with Camel on Openshift – part 1 […]
[…] EAP Webservice with Camel on Openshift – part 1 […]