Recently, I was working for one customer and they asked me if we can build REST based services out of SOA Suite or OSB 11g. My answer was clear, they could either use HTTP adapter from SOA Suite in composite or use HTTP transport out of OSB. Only http POST and GET verbs are available from HTTP adapter, where as in OSB 11g we can use most of the REST verbs through HTTP transport.
So my obvious choice was to use OSB http transport because of its VERB support and we can use conditional branch to process each VERB separately in OSB pipeline. One more advantage of using OSB transport over http adapter from SOA Suite was URL. If we use http adapter from SOA Suite we need to add operationName parameter at the end of the REST URL.
So that’s all done, now customer asked one more question, can we resolve target URI dynamically based on some parameter from incoming request header?
For example:
We have a REST service deployed with two separate operations and have following URLs
and
And now we have OSB routing service which accepts the request from client and routs it to either operation1 or 2. OSB routing proxy service URL looks like this
So when client calls above proxy service they will instruct OSB routing service which operation to call.
There are few other ways to do this. Such as we can store above target service URLs as XML resource file in out OSB routing service and use conditional branch to do routing using ROUTING OPTION component by setting URI parameter.
When discussing this requirement further with the customer, they mentioned there could be N number of operations and they should be able to build and then deploy them any time. But then every time they build a new REST service they don’t want to go back and change the OSB routing service.
One good way to achieve above requirement is through http:relative-URI element of request header in HTTP transport.
If client calls the proxy service with following URL (adding TestServiceOperation1 as a post fix)
http://localhost:7001/TestRESTClient/TestRESTClientPRoxyService/TestServiceOperation1
And now we can in OSB routing service we can create a Business Service with base URI
And we can Insert http:relative-URI element as last child of $outbound/ctx:transport/ctx:request to outbound transport headers when routing to that business service.
That way target service URI will be automatically resolved to