Thiru
Thiru

Reputation: 424

Callout and send mediator in wso2 esb

Can anybody explain with generic example what callout mediator does? and how to configure source and target ? How callout mediator is different from send mediator?

Upvotes: 1

Views: 1130

Answers (2)

Philipp
Philipp

Reputation: 4729

You can find a good explanation in the WSO2 Documentation of the Callout Mediator.

  • Source: Defines the payload for the request. There are three options (XPath, Property, Envelope) to define where the payload comes from. Most of the time we use Envelope to send the complete content.
  • Target: Defines where the response should be stored. There are options (XPath and Property), to either set the response in the current message or inside a property.

Here is a simple example we often use to send the whole content and store the response inside a property:

<callout serviceURL="http://wsf.cdyne.com/WeatherWS/Weather.asmx" action="http://ws.cdyne.com/WeatherWS/GetWeatherInformation">  
     <source type="envelope"/>
     <target key="response"/>
</callout>

<!-- print the response property -->
<log level="custom">
    <property name="response" expression="get-property('response')"/>  
</log>

You can find another example here.

Upvotes: 1

krishan
krishan

Reputation: 579

'source' specifies the payload for the request message using an XPath expression (We can select desired xml nodes to send as a request) or a registry key (where we can store the request message in the registry). The 'target' specifies a node at which the resulting payload (response) will be attached in the current message context.

The difference between callout mediator and send mediator is that callout mediator will return the response to the same sequence by doing a blocking call. So the callout mediator keeps the thread until transaction done.

In send mediator response is returned to the OutSequence in where you can send it back to the client.So the thread will release immediately sending the message out.

This is a good blog where you can find the usage.

Upvotes: 3

Related Questions