August 1, 2016
Primer: Calling Multiple REST Services
This is the shortest guide for making an OSB parallel call to REST services with GenericParallel.
I assume the GenericParallel service is already deployed on your domain. If not, here’s the deployment guide.
Suppose we need to call a RESTful service named RegisterResourceId. We’ll need to register a number of ids at once, hence the parallel call.
To register one id, we need to call this service with the following parameters:
Base URL | http://datagrid/restful |
Relative URI | register-resource-id |
HTTP Method | PUT |
Payload | Resource ID itself |
The base URL is configured on a business service, let’s call it Datagrid/Biz/Restful.
Now we need to call this business service, passing correct relativeURI and HTTP method, and do it in parallel.
GenericParallel will do all of it for you, you just need to:
Create a GenericParallel wrapper request.
Add a list of REST requests to the wrapper.
Pass that wrapper request to GenericParallel/GenericParallel local proxy.
Read the responses from the GenericParallel wrapper response.
For example, let’s register two resource ids:
<typ:GPS xmlns:typ="http://genericparallel/types">
<typ:Requests>
<typ:Request GPSTargetType="BusinessService" GPSRelativeURI="register-resource-id" GPSMethod="PUT" GPSTarget="Datagrid/Biz/Restful">
ad41115e-9e26-11e5-8994-feff819cdc9f
</typ:Request>
<typ:Request GPSTargetType="BusinessService" GPSRelativeURI="register-resource-id" GPSMethod="PUT" GPSTarget="Datagrid/Biz/Restful">
927e4e10-a21b-11e5-bf7f-feff819cdc9f
</typ:Request>
</typ:Requests>
</typ:GPS>
Now pass this request to GenericParallel/GenericParallel proxy.
GenericParallel will take every Request entry and execute them in parallel by calling the business service at path Datagrid/Biz/Restful, setting relativeURI to register-resource-id, HTTP method to PUT and body to anything that is under Request - UUID in this case.
Then it will collect the responses and return them back as a list in the same order as they were sent out:
<types:GPSResponse xmlns:types="http://genericparallel/types">
<types:Responses>
<types:Response GPSIndex="1" GPSBatchIndex="1">
<soap-env:Envelope>
<soap-env:Body>+OK Registered</soap-env:Body>
</soap-env:Envelope>
</types:Response>
<types:Response GPSIndex="2" GPSBatchIndex="1">
<soap-env:Envelope>
<soap-env:Body>+OK Registered</soap-env:Body>
</soap-env:Envelope>
</types:Response>
</types:Responses>
</types:GPSResponse>
Note: the responses are always wrapped into soap-env:Body.
If you want to learn more, feel free to try GenericParallel.
About Me
My name is Vladimir Dyuzhev, and I'm the author of GenericParallel, an OSB proxy service for making parallel calls effortlessly and MockMotor, a powerful mock server.
I'm building SOA enterprise systems for clients large and small for almost 20 years. Most of that time I've been working with BEA (later Oracle) Weblogic platform, including OSB and other SOA systems.
Feel free to contact me if you have a SOA project to design and implement. See my profile on LinkedIn.
I live in Toronto, Ontario, Canada. Email me at info@genericparallel.com