JBoss ESB has a lot of pre-defined actions which can be used to proxy request to other services/protocols. One interesting one is the HttpRouter which allows the invocation of external (ESB unaware) Http endpoints from an ESB action pipeline. This action uses Apache Commons HttpClient under the covers.
In this short tutorial we will see, how to proxy your REST service invocations with JBoss ESB.
Supposing you have defined a REST service with the following GET method:
In order to invoke this REST service we will configure an HttpRouter action in a basic jboss-esb.xml file:
Note: this action requires a file named ht.props at the root of the .esb archive which contains client's http connection properties. Including a property file is optional, however it s is generally used for fine tuning the http connection. For example, here are two properties you might include in your ht.props file:
You might add a bit more of complexity to your service by passing Header parameters to your REST service:
Header parameters will be sent using the "header" element, inside the "property" section:
For your reference, here's the list of properties supported by the HttpRouter action:
Setting this to
The endpoint to which the message will be forwarded.
The HttpRouter uses the HttpClientFactory to create and configure the HttpClient instance. You can specify the configuration of the factory by using the file property which will point to a properties file on the local file system, classpath or URI based.
Currently only supports GET and POST.
Specifies in what form the response should be sent back. Either STRING or BYTES. Default value is STRING.
To be added to the request. Supports multiple <header name="test" value="testvalue" /> elements.
A comma separated list of header names that should be propagated to the target endpoint.