Specialized REST Adapter
Popular open source ESB products, such as
Mule, provide REST adapters as part of their product offerings. Mule offers a REST wrapper that is very simple to set up and configure. Configuration steps include setting up all the common parameters that characterize the RESTful web service, such as URL, HTTP method type, query parameters, HTTP error handler, etc.
The following is an example of Mule's configuration file for the RESTful adapter, which invokes the RESTful web service presented in my previous DevX article "RESTful Web Services: The Keep-It-Simple Style":
<mule-descriptor name="HTTPPostSample" implementation="org.mule.components.rest.RestServiceWrapper"
singleton="false" initialState="started">
<inbound-router matchAll="false">
<endpoint address="stream://System.in" type="senderAndReceiver" />
</inbound-router>
<outbound-router matchAll="false">
<router className="org.mule.routing.outbound.FilteringOutboundRouter" enableCorrelation="IF_NOT_SET">
<endpoint address="stream://System.out" transformers="XmlDecoder Xslt XmlToObject" type="senderAndReceiver" />
</router>
</outbound-router>
<properties>
<property name="serviceUrl" value="http://mycompany.com/shipments/PrintShipmentRoute" />
<property name="payloadParameterName" value="shipment_id" />
<property name="httpMethod" value="GET" />
</properties>
</mule-descriptor>
All other parameters such as payloadParameterName are optional, but the urlFromMessage parameter is of particular interest when integrating ESB Mule with canonical web services.
With this parameter set, Mule ESB will look into a message for the value of the rest.service.url parameter, which represents the URL of the RESTful web service to be invoked.
This option enables Mule to access RESTful URLs that universally represent entities (e.g., shipment ID is part of the URL), which is in accordance with the best practices for RESTful web services.