This documentation is for WSO2 ESB version 4.5.1. View documentation for the latest release.

Callout Mediator

The Callout Mediator performs a blocking external service invocation during mediation. The service URL and the optional action specify the parameters for this external call.

As the Callout Mediator performs a blocking call, it cannot use the default non-blocking http/s transports based on Java NIO. Therefore, it defaults to using the samples/axis2Client/client_repo/conf/axis2.xml as the Axis2 configuration and samples/axis2Client/client_repo as the client repository unless these are specified separately.

  • This version of ESB does not support retrieving original error codes such as 404 when you use the Callout mediator since this mediator uses Blocking transport. This feature is supported in ESB 4.8.0 and later versions.
  • The Commons HTTP Transport Sender used in the Callout mediator only creates two connections per host at a time. As a result, the back end server can get late to respond to requests. A time out exception can occur in such situations. To avoid this, you can set the parameters for the Commons HTTP Transport Sender as follows in <ESB_HOME>/samples/axis2Client/client_repo/conf/axis2.xml.

    <transportSender name="http" class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
    <parameter name="PROTOCOL">HTTP/1.1</parameter>
    <parameter name="Transfer-Encoding">chunked</parameter>
    <parameter name="cacheHttpClient">true</parameter>
    <parameter name="defaultMaxConnectionsPerHost">200</parameter>
    <!-- If following is set to 'true', optional action part of the Content-Type will not be added to the SOAP 1.2 messages -->
    <!-- <parameter name="OmitSOAP12Action">true</parameter> -->
    </transportSender>

    Increasing the value specified for the defaultMaxConnectionsPerHost as shown above can avoid timeouts that can occur due to limited connections.




Syntax

<callout serviceURL="string" [action="string"]>
      <configuration [axis2xml="string"] [repository="string"]/>?
      <source xpath="expression" | key="string"/>
      <target xpath="expression" | key="string"/>
</callout>
  • source - The element specifies the payload for the request message using an XPath expression or a registry key that will be used.
  • target - The element specifies a node at which the resulting payload will be attached into the current message, or the name of a key/property using which the response will be attached to the current message context as a property.

UI Configuration

The following properties of the Callout Mediator are available:

General Options of the Callout Mediator
  • ServiceURL - URL of the service.
  • Action - SOAP action.
  • Axis2 Repository - Full path to Axis2 Repository Location. This is the place where services and modules are.
  • Axis2 XML - Full path to Axis2 XML file location.
Source

It specifies the payload for the request message using an XPath expression or a registry key that will be used. Can be specified as:

  • XPath - Can be chosen from the "Namespace Editor" list.
  • Key - Can be chosen either from Configuration Registry or Governance Registry. Refer to more information about the Registry Browser in Namespace.
Target

It specifies a node, at which the resulting payload will be attached into the current message, or the name of a key/property using which the response will be attached to the current message context as a property. Can be specified as:

  • XPath - Can be chosen from the "Namespace Editor" list.
  • Key - Can be chosen either from Configuration Registry or Governance Registry. Refer to more information about the Registry Browser in Namespace.

Tip

You can click the "Namespaces" link to add namespaces if you are providing an expression. You will be provided another panel named "Namespace Editor" where you can provide any number of namespace prefixes and the URL used in the XPath expression.

Note

You can configure the Mediator using XML. Click on "switch to source view" in the "Mediator" window.

Example

<callout serviceURL="http://localhost:9000/services/SimpleStockQuoteService"
         action="urn:getQuote">
    <source xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/"
            xmlns:s12="http://www.w3.org/2003/05/soap-envelope"
            xpath="s11:Body/child::*[fn:position()=1] | s12:Body/child::*[fn:position()=1]"/>
    <target xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/"
            xmlns:s12="http://www.w3.org/2003/05/soap-envelope"
            xpath="s11:Body/child::*[fn:position()=1] | s12:Body/child::*[fn:position()=1]"/>
</callout>

In this example, the Callout Mediator does the direct service invocation to the StockQuoteService using the client request, get the response and set it as the first child of the SOAP message body. Then using the Send Mediator, the message is sent back to the client.