Petals-BC-REST 1.x

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
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

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.

Usage

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

Provides an external Web Service as a JBI service

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 REST request is created according the HTTP method to used:

  • GET:
  • The REST URI is created from the address extension, JBI operation and JBI payload (only the children of the XML root of the JBI payload are used, the local name is the URI parameter name and the content of the tag is the URI parameter value).
  • There is no HTTP body
  • POST:
  • The REST URI is created from the address extension and the JBI operation.
  • The HTTP body is created from the JBI payload (The value of the XML root of the JBI payload is used)
  • PUT:
  • The REST URI is created from the address extension and the JBI operation.
  • The HTTP body is created from an attachment (the first attachment found in the JBI message is used if there is one)
  • DELETE:
  • The REST URI is created from the address extension and the JBI operation.
  • There is no HTTP body
    For all the HTTP methods, the headers present in the protocol header JBI message property are added to the HTTP headers.

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 200) a JBI fault is created.
  • The HTTP body if it is present is used to create a JBI attachment (the HTTP body is not a XML in all the cases).
  • The JBI payload is empty.
  • The HTTP headers are added to the protocol header JBI message property

In all the cases, the MEP used to call the RESTful services is defined by the petalsCDK:mep extension.

With no description of the RESTful Web Service

The HTTP method is defined in the http-method SU extension.

With a 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.

With a 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.

Configuration

Configuration of a Service Unit to provide a service (JBI)

Parameter Description
Default
Required
provides Describe the JBI service that will be exposed into the JBI bus. Interface (QName), Service (QName) and Endpoint (String) attributes are required. - Yes

Configuration of a Service Unit to provide a service (CDK)

Parameter Description
Default
Required
timeout Timeout in milliseconds of a synchronous send. This parameter is used by the method sendSync (Exchange exchange) proposes by the CDK Listeners classes.
Set it to 0 for an infinite timeout.
30000 No
exchange-properties This sections defines the list of properties to set to the JBI exchange when processing a service. - No
message-properties This sections defines the list of properties to set to the JBI message when processing a service. - No
validate-wsdl Activate the validation of the WSDL when deploying a service unit. true No
wsdl
Path to the WSDL document describing services and operations exposed by the provided JBI endpoints defined in the SU.
The value of this parameter is :
  • an URL
  • a file relative to the root of the SU package
    If not specified, a basic WSDL description is automaticaly provided by the CDK.
- No
forward-attachments
Defines if attachment will be forwarded from IN message to OUT message.
false No
forward-message-properties
Defines if the message properties will be forwarded from IN message to OUT message. false No
forward-security-subject
Defines if the security subject will be forwarded from IN message to OUT message. false No


Service Unit attributes to provide services

Attribute Description Default value Required
address Address of the external Web Service to send JBI messages to.  
Yes
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.
 
Yes*
wadl WADL which defines the partner service  
Yes*
wsdl2 WSDL2 which defines the partner service  
Yes*

*Only one of these extensions must be used and is required in a specific SU.

Service Unit descriptor

The service unit is configurable via its extensions in the jbi.xml file:


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

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.

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:

Consumes a JBI service on a REST message

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.

Configuration

Configuration of a Service Unit to consume a service (JBI)

Parameter Description Default Required
consumes Refer JBI service to invoke into the JBI bus.
You can define an explicit endpoint: interface (QName) / Service (QName) / Endpoint (String) attributes.
Or define implicit endpoint, to let the container routing according to QOS configurations (HA...):
-by Interface attribute (QName)
-by Service attribute (QName)
- Yes


Configuration of a Service Unit to consume a service (CDK)

Parameter Description Default Required
mep Message exchange pattern abbreviation. This parameter can be used in conjunction with the method of the CDK Listeners: createMessageExchange(Extensions extensions).
This method returns a CDK Exchange corresponding to the type of the specified pattern.
- Yes
operation Operation to call on a service. This parameter can be used in conjunction with the sending methods of the Listeners. If no operation is specified in the Message Exchange to send, this parameter will be used. - No
timeout Timeout in milliseconds of a synchronous send. This parameter can be used in conjunction with the sendSync(Exchange exchange) method of the Listeners. Set 0 for an infinite timeout. 30000 No


Service Unit attributes to consume services

Attribute Description Default value Required
service-name Web Service name to expose.  
No

Service Unit descriptor

The service unit is configurable via its extensions in the jbi.xml file:


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
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.