EAP Webservice with Camel on Openshift – part 3


This post follows on from

Part 3 – Moving our EAP to Openshift

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.

Create an Openshift Project from our EAP

This section assumes that you have already created a free account on Openshift.com

  • Open JBoss Developer Studio
  • Open JBoss Central
  • Click Openshift Application
  • Enter your Openshift username and password
  • click next
  • Enter a name for your application – eapWS
  • Change the type to jbosseap-6
  • Set the Gear profile to small
018-openshiftApp
  • click next
  • uncheck Create a New Project
  • Browse and select our existing project – camel-cxf-contract-first
019-openshiftApp
  • click next
  • click finish
020-gitclone

JBoss Developer Studio will display a popup window detailing the procedure it is following to create your Openshift project:

021-deploy

This process may take quite some time.

Reviewing our Application

If we use FileManager to look at our application, you will note that this process has added a .git directory and other git related folders and files for the application and also a .openshift directory.

Furthermore, the application has been uploaded to Openshift, the jbosseap cartridge has been deployed and the cartridge has been started.

022-deploylog

If we take a look at Openshift we can see our new application:

023-openshiftapp

However, if we try to connect to the endpoint or look at the WSDL we will have a problem – so let’s have a look.

Can’t see the WSDL!!

First, before we can try and look at the WSDL, we need to find out the Endpoint address.  There are  a number of ways to do this, but my preferred route is as follows:

Start Portforwarding to see the Openshift EAP Console

Open a command terminal on your computer, and type in the following command:

rhc port-forward eapWS

On my terminal, I get the following output generated:

024-portforward

We are interest in access the EAP instance on Openshift using port 9990 to see the admin console.

We can see from the output, that we now have port forwarding set up to that address from 127.0.0.1:9991.

Open a browser window and navigate to that address:

025-eapconsole

From within the console navigate to:

Runtime -> status -> subsystems -> Webservices

026-webservices

Here, we can see that the WSDL url is: http://eapws-skills421.rhcloud.com:80/ROOT/OrderEndpointService?wsdl

but if we click on this link, we get an error that tells us that JBWEB000124: The requested resource is not available.

Once you have finished, enter Ctrl-C in the command terminal to quit port forwarding.

Fixing the WebService Errors

The problem, as pointed out by Magesh Bojan at Red Hat is simply that The default application is deployed to the server as ROOT.war and hence the WebService gets registered under http://***.rhcloud.com/ROOT/…

We can get round this by adding a jboss-web.xml file under WEB-INF.

  • Open your camel-dxf-contract-first app in JBoss Developer Studio
  • in Project Explorer navigate to src/main/webapp/WEB-INF
  • add jboss-web.xml as follows
<jboss-web>
<context-root>/</context-root>
</jboss-web>
  • right click on the file in Project Explorer
  • Team -> Commit
  • Add a comment – something like – added jboss-web.xml to resolve root deployment issues
  • Click commit (do NOT click commit and push)

Pushing the Fixes to Openshift

  • Open a command terminal
  • Navigate to your application folder
  • type git push

The jbosseap cartridge will be stopped, the project will be rebuilt, re-deployed and the cartridge will be re-started.

If you want to see the log, open a second command terminal and enter the following command: rhc tail eapWS

Back to the Webservice Endpoint

Once the cartridge has re-started, open a command terminal on your computer, and type in the following command:

rhc port-forward eapWS

Open a browser window and navigate to the port that maps to 9990. In my case it is localhost:9991

From within the console navigate to: Runtime -> status -> subsystems -> Webservices

Identify the WSDL url – in my case – http://eapws-skills421.rhcloud.com:80/OrderEndpointService?wsdl

Click on the link and hey presto – a wsdl file:

027-openshiftWSDL

Send a message to the Webservice Endpoint

From the second blog in this series, we know that the address url to send messages is:

  • The context of the deployment – http://eapws-skills421.rhcloud.com
  • The context path of the CXF servlet, as set in web.xml – /soap/
  • The CXF endpoint, as set in camel-cxf.xml – /order

This gives: http://eapws-skills421.rhcloud.com/soap/order

Open SoapUI and enter this url into the Request 1 address as per the second blog and click send.

Hey presto – we have successfully sent a message to our Openshift-hosted Webservice end point.  This has been routed using Camel to a SEDA queue and the response of OK has been returned.

Job done! – for now.

028-soapsent

2 comments

Leave a reply to EAP Webservice with Camel on Openshift – part 2 | Skills421 Cancel reply