Skip to main content

Posts

Showing posts from December, 2014

JBoss Fuse - Implementing WebService with Camel using CXF SOAP and Restful with CXFRS. Part Two

Continue from last post, this time I am going to add a restful web service endpoint to our insurance application, and show you use the CXF producer. :)


Similar to CXF web service, we need to create a resource file, but this time, instead of an interface, we need to create a java class. Within the resource class file, we have specify 2 things, the context path and the url path of each functions for the restful service. So in the java file below, you will see that I have declare "status" context path for our status service, "/custId/{id}" for getting the status and "/restcancel/{polno}" for canceling claim with restful API.


package org.blogdemo.claimdemo; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; @Path("/status") public class StatusService { @GET @Path("/custId/{id}") @Produces(MediaType.APPLICATION_JSON) public ClaimStatus status…

JBoss Fuse - Implementing WebService with Camel using CXF SOAP and Restful with CXFRS. Part One

Some friend of mine in Japan asking if I could do a simple demo on Camel CXF,  So here it is :).
This demo is about an insurance simple online claim application and status update. I will show you how to use Camel CXF to quickly setup an WebService, also setup Restful WebServices in few very easy steps.

In this demo we are going to setup a web service that takes in customer's insurance claim application, also provide another cancel function in case they have changed their mind.

One of the reason I love so much about Camel is that I don't need to deal with different context of the data, like XML, JSON... I mean they are ok, but I like POJO more, as a Java developer they are more meaningful and much easier to play with. So now we are going define some POJOs that we are going to exchange in this demo.

These two POJO contains the application information required (ClaimInput) and the result of the application submission (ClaimOutput).
package org.blogdemo.claimdemo; import java.util…

JBoss Fuse - File Connector with Split Pattern and JDBC connector with Error Handling - Part Two

This is the second part of the demo, "JDBC connector with Error Handling ", please take a look at the previous blog post. You can also find the finished code base here.

In the XML file, you'll find there is a VIP status, this indicates the process fee we need to charge per transaction, for DIAMOND class VIP, it's $1, $2 for GOLD and $3 for other accounts.

Using JDBC Connector, we first must create datasource setting, either within Camel context xml or in Fabric8. To make testing easy, we will set the setting in the datasource.

XML
Here you will see I use the H2 Database in memory, I am using it because it's easier to setup, without the need of installing a database. If you want, you can always change it to your desire database, all you have to do is just replace the driverClassName and url, along with the ID and password to access the database. And then it's always a good idea to include an transaction manager so we can set the transaction policy. 
Before calling …

JBoss Fuse - File Connector with Split Pattern and JDBC connector with Error Handling - Part One

This demo is slightly longer then the ones I done before, So I will break it into 2 parts, and try to keep each section as simple as possible, and then combine 2 simple section into a bigger demo. During the process I hope you can find it's very simple to integrate, process data and information with JBoss Fuse.

Part One
=========

File connectorSplit Pattern

We are going to take in XML file from different branch in a directory, each contains cash deposit, cash withdraw and transfer data, depending on the type of transaction, we spilt this XML file into different sections, then send them to different services for further process.

The format of a XML looks like this.  A02Gold-20A02GoldA0120


First create a route that has a file consumer endpoint that read xml files from directory, there are many different options like, readLock - locks the file when reading it , recursive -look for files in all the sub-directories as well , extra.. for more options please read the documentation. After r…