View Source

{section}
{column}

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 Restlet, Jersey, Resteasy, CXF or Axis2 (TBD). It provides the following features:
* Expose Restful Web Services as JBI Services
* Expose Restful Web Services as JBI Services using a WADL
* Expose Restful Web Services as JBI Services using a WSDL 2.0
* 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}

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 address of the Web Service to send the REST message to is defined in the address extension of the deployed Service Unit.

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

h3. With no description of the RESTful Web Service

The REST message is created like this:
* The JBI message payload is wrapped in the SOAP body
* The JBI message attachments are used to create SOAP ones
* The JBI message exchange operation is used to create the SOAP action
* The JBI MEP is used to determine the SOAP MEP

h3. With a WADL

h3. With a WSDL 2.0


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} |
{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,
* 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 from the SOAP action.
* Copy the SOAP body into the JBI one.
* Put the SOAP attachments into JBI ones.
* Put the SOAP headers into the protocol header JBI message property.


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
{column}
{column:width=25%}
{panel:title=Table of contents}{toc}{panel}
{panel:title=Contributors}{contributors:order=name|mode=list}{panel}
{column}
{section}