Monday, April 11, 2011

Rest Support from OSB


Couple of times we need to call Rest based services like HTTP Post from OSB/SOA layer, as of now there is no well defined adapter for this. Most of the times we end up using POJO for this.The HTTP adapter provided in SOA is quite basic and doesnt generally fits the requirement like when calling services with complex input data like multi-mime etc.
Here is steps that can be followed , however its completely driven by the requirement and need to be customized accordingly.
Use case :
- HTTP Post service that has to be called
- Input is multi mime and handshake is through the boundary defined
- No ssl or any other security need.

Steps:
1. Create a Business service in OSB
Service Type : Messaging Service
Request/Response Message Type   : Text
Protocol  : html
Endpoint URI  : http://mysupplier/serviceendpoint/
HTTP Request Method  : POST

Test this with your multimime input from test console,
pass the input in body and Content-Type: multipart/form-data; boundary=scm-shipping-oracle;utf-8

2. Create proxy based on the business service .
Service Type : Messaging Service
Request/Response Message Type   : Text
Protocol  : html

Test this with your multimime input from test console ,
pass the input in body and Content-Type: Content-Type: multipart/form-data; boundary=scm-shipping-oracle;utf-8

- You can add alert here to display the body and attachment data

3. Create another proxy to call the proxy created in previous step, I added this to put customization logic and to not

disturb the proxy->Buss service route created in previous step.

In message flow :
- Set Transport Headers for outbound request
Content-Type: Content-Type: multipart/form-data; boundary=scm-shipping-oracle;utf-8

- Add Java callout to read the attachment data , the java callout must return org.apache.xmlbeans.XmlObject
- add replace for attachment with the java callout output [replace entire node]
- While responding can add another java callout to write the attachment , can use xs:string($attach_resp) to cast attachment to string.

This all is done.

4. Now to call this from bpel can add a proxy based on wsdl that calls the proxy created in 3rd step.

This works !!

No comments:

Post a Comment