Reputation: 11
I would like to comunicate two web services thorugh an ESB in my case WSo2, for that i have to set and endpoint and a proxy service, but i cant solve it.
Any idea?, Any tutorial?
Upvotes: 0
Views: 591
Reputation: 1213
First you should pick between a Proxy Service and API in ESB. A proxy service will give you a SOAP endpoint to work with and an API will give you a RESTful endpoint.
But which ever you chose, the rest is all the same. There will be an inSequence that gets triggered when you invoke your Proxy Service or API. In your inSequence you will have to mix and match a set of mediators and tailor them to your needs. A mediator is a unit of work in your integration flow.
For instance, a service chaining scenario can go something like:
Have a look at the inSequence below which does the steps above. You can drop this into a proxy or API.
<inSequence>
<log level="custom">
<property name="Lets log the incoming payload" expression="$body"/>
</log>
<!-- Payload for first backend -->
<payloadFactory media-type="json">
<format>
"payload":{
"name":"StackOverflow",
"value":"SO"
}
</format>
</payloadFactory>
<!-- Invoke backend 1 -->
<call>
<endpoint>
<http uri="http://backend1/jsonEndpoint" method="post"/>
</endpoint>
</call>
<!-- At this point we have the response from backend1 in the message context -->
<log level="custom">
<property name="Lets log the payload from backend1" expression="$body"/>
</log>
<!-- Payload for second backend. We are using JSONPath to access a value from backend1's payload here -->
<payloadFactory media-type="json">
<format>
"payload":{
"name":"StackOverflow",
"value":"SO",
"id": $1
}
</format>
<args>
<arg expression="$.response.from.backend1.id"/>
</args>
</payloadFactory>
<!-- Invoke backend 2 -->
<call>
<endpoint>
<http uri="http://backend2/endpoint" method="post"/>
</endpoint>
</call>
<!-- At this point we have the response from backend2 in the message context -->
<log level="custom">
<property name="Lets log the payload from backend2" expression="$body"/>
</log>
<!-- Respond back to client -->
<respond/>
</inSequence>
I haven't tested the above sequence, but it should be fairly accurate. To get you started, here are the docs to everything we used above.
Upvotes: 2