View Source

{section}
{column}

{warning}This version must be installed on Petals ESB 5.0.2+{warning}

h1. Feature

The REST component is a Binding Component (BC) which enables to interact with external RESTful Web Services and to expose JBI services as RESTful Web Services.

In provider role, when a JBI MessageExchange is sent to a ServiceEndpoint (mapped to a Web Service), it is transformed into a REST message and sent to the linked external Web Service. In consumer role, when a REST message is received on an exposed Web Service, it is transformed into a JBI MessageExchange and sent to the corresponding JBI ServiceEndpoint.

The REST component is based on Jersey and Axis2 (TBD). It provides the following features:
* Expose Restful Web Services as JBI Services
* Expose Restful Web Services as JBI Services using a WADL (TBC)
* Expose Restful Web Services as JBI Services using a WSDL 2.0 (TBC)
* Expose JBI Services as Restful Web Services


{info}
REST is a style of software architecture not a standard. If you want more details about REST, you can consult the Wikipedia page: [http://en.wikipedia.org/wiki/Representational_State_Transfer]
{info}
{column}
{column:width=25%}
{panel:title=Table of contents}{toc}{panel}
{panel:title=Contributors}{contributors:order=name|mode=list}{panel}
{column}
{section}

h1. Exposing an external Restful Web Service as a JBI service endpoint

In provide mode, the component exposes an external Web Service in the JBI environment to send REST requests to the external Web Service.

h2. Usage

The petals-bc-rest component can expose an external Web Service as a JBI service endpoint by deploying a Service Unit on it:

{center}

*Provides an external Web Service as a JBI service*
{center}

When a message is received on a REST linked endpoint from the JBI environment, it is transformed into a REST message and sent to the Web Service.

The REST request is created like this:
* The REST URI is created from the address extension, the JBI operation and JBI message content (The JBI message content must contains the information about the path, the matrix and query parameters)
* The HTTP body is created differently according the HTTP method to used:
** GET/DELETE: There is no HTTP body
** POST: The HTTP body is also created differently according the JBI message content:
*** The JBI message content contains only a reference to a JBI attachment: The HTTP body is created from a JBI attachment (binary data)
*** The JBI message content does not contains a reference to a JBI attachment: The HTTP body is created from the JBI message content (form parameters)
** PUT: The HTTP body is created from a JBI attachment
* The headers present in the protocol header JBI message property are added to the HTTP headers.

For example the following JBI message:
{code:lang=xml}
{code}

produces the URI [http://weather.yahooapis.com/]....

The external Web Service is called and the REST response is processed and returned to the JBI environment.

The REST response is transformed into a JBI message like this:
* In case of error (HTTP status different from 20x) a JBI fault is created.
* The JBI message content and attachment are created differently according the Content-Type HTTP header:
** Non XML content types: The JBI message content is a reference (cf SOAP) to a JBI attachment which contains the HTTP body
** XML content types: The JBI message content is created from the HTTP body (there is no JBI attachment created)
* The HTTP headers are added to the protocol header JBI message property


h3. With no description of the RESTful Web Service

The address of the RESTful Web Service is defined in the address extension of the deployed Service Unit.
The HTTP method is defined in the http-method SU extension.

h3. With a WADL

The address of the RESTful Web Service is found in the WADL.
The REST operation corresponding to the JBI operation is found in the WADL.
The HTTP method is defined in the WADL for the operation.

h3. With a WSDL 2.0

The address of the RESTful Web Service is found in the WSDL 2.0.
The REST operation corresponding to the JBI operation is found in the WSDL 2.0.
The HTTP method is defined in the WSDL 2.0 for the operation.

h2. Configuration

{include:0 CDK SU Provide Configuration}
\\
{center}{*}Service Unit attributes to provide services{*}{center}
{table-plus}
|| Attribute || Description || Default value || Required ||
| address | Address of the external Web Service to send JBI messages to. | | {center}Yes\*{center} |
| http-method | HTTP method to use. \\
\\
Possible values are: GET for the HTTP method GET, POST for the HTTP method POST, PUT for the HTTP method PUT and DELETE for the HTTP method DELETE. \\ | | {center}Yes\*{center} |
| wadl | WADL which defines the partner service | | {center}Yes\*{center} |
| wsdl2 | WSDL2 which defines the partner service | | {center}Yes\*{center} |
{table-plus}

\*Either address and http-method extensions or wadl or wsdl2 must be present in a specific SU.

h3. Service Unit descriptor

The service unit is configurable via its extensions in the jbi.xml file:
{code:lang=xml}
{code}

h3. Service Unit content

The Service Unit has to contain the following elements, packaged in an archive:
* The META-INF/jbi.xml descriptor file as described above,
* An optional imported WADL/WSDL 2.0 file describing the partner service


h1. Exposing an internal JBI service endpoint as a RESTful Web Service

In consumer mode, the component exposes an internal JBI service outside the bus to transfer incoming REST requests to the internal service.

h2. Usage

The petals-bc-rest component can listen incoming REST messages and send messages to a JBI service endpoint by deploying a Service Unit on it. The component consumes the JBI service:


{center}

*Consumes a JBI service on a REST message*
{center}

The service-name Service Unit extension value will be used as service name.

When a REST message is handled by the component, it is transformed into a JBI Message and sent to the JBI service endpoint configured in the Service Unit.

The JBI message is created like this:
* The JBI operation is created differently from the operation present in the REST URI operation
* The JBI message content is created according to the HTTP method of the incoming REST request:
** GET: The JBI message content is created from the REST URI path and parameters
** POST: The JBI message content is also created differently according the Content-Type HTTP header:
*** Non XML content types: The JBI message content is a reference (cf SOAP) to a JBI attachment which contains the HTTP body
*** XML content types: The JBI message content is created from the HTTP body (there is no JBI attachment created)
** PUT/DELETE: There is no JBI message content
* A JBI attachment is created according to the HTTP method of the incoming REST request:
** GET/DELETE: There is no JBI attachment created
** POST: A JBI attachment is created from the HTTP body if the Content-Type HTTP header contains a non XML content type.
** PUT: A JBI attachment is created from the HTTP body
* The HTTP headers are added to the the protocol header JBI message property
* The MEP is defined by the petalsCDK:mep extension.

A WADL is available at the following URL: (TBC)
A WSDL 2.0 is available at the following URL: (TBC)

h2. Configuration

{include:0 CDK SU Consume Configuration}
\\
{center}{*}Service Unit attributes to consume services{*}{center}
{table-plus}
|| Attribute || Description || Default value || Required ||
| service-name | Web Service name to expose. | | {center}No{center} |
{table-plus}

h3. Service Unit descriptor

The service unit is configurable via its extensions in the jbi.xml file:
{code:lang=xml}
{code}

h3. Service Unit content

The Service Unit has to contain the following elements, packaged in an archive:
* The META-INF/jbi.xml descriptor file as described above

h1. Monitoring the component

h2. Using metrics

Several probes providing metrics are included in the component, and are available through the JMX MBean '{{org.ow2.petals:type=custom,name=monitoring_*<component-id>*}}', where {{*<component-id>*}} is the unique JBI identifier of the component.

h3. Common metrics

{include:0 CDK Component Monitoring Metrics 5.6.0}

h3. Dedicated metrics

No dedicated metric is available.

h2. Receiving alerts

Several alerts are notified by the component through notification of the JMX MBean '{{org.ow2.petals:type=custom,name=monitoring_*<component-id>*}}', where {{*<component-id>*}} is the unique JBI identifier of the component.

{tip}To integrate these alerts with Nagios, see [petalsesbsnapshot:Receiving Petals ESB defects in Nagios].{tip}

h3. Common alerts

{include:0 CDK Component Monitoring Alerts 5.6.0}

h3. Dedicated alerts

No dedicated alert is available.