## Apache Synapse

## Sample 850: Introduction to Synapse Callout Block function template

<!-- Introduction to Synapse Callout Block function template --> <definitions xmlns="http://ws.apache.org/ns/synapse"> <import xmlns="http://ws.apache.org/ns/synapse" name="EipLibrary" package="synapse.lang.eip" /> <sequence name="main"> <call-template target="synapse.lang.eip.callout_block"> <with-param name="action" value="urn:getQuote"/> <with-param name="service_URL" value="http://localhost:9000/services/SimpleStockQuoteService"/> <with-param xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/" xmlns:s12="http://www.w3.org/2003/05/soap-envelope" name="source_xpath" value="{{s11:Body/child::*[fn:position()=1] | s12:Body/child::*[fn:position()=1]}}"/> <with-param xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/" xmlns:s12="http://www.w3.org/2003/05/soap-envelope" name="target_xpath" value="{{s11:Body/child::*[fn:position()=1] | s12:Body/child::*[fn:position()=1]}}"/> </call-template> <respond/> </sequence> </definitions>

### Objective

This pattern is pretty much identical to the Routing slip pattern and this blocks external service invocation during mediation. And useful in scenarios such as service chaining. As default values are assigned to source and target xpaths, one can simply utilize this pattern by just defining serviceURL. This sample is an introduction to Synapse Callout Block function template.

### Pre-requisites

- Deploy the SimpleStockQuoteService in the sample Axis2 server and start Axis2
- Start Synapse using the configuration numbered 850 (repository/conf/sample/synapse_sample_850.xml)
  Unix/Linux: sh synapse.sh -sample 850
  Windows: synapse.bat -sample 850

### Executing the Client

In this sample, the callout block pattern does a synchronized service invocation to the StockQuoteService using the client request, gets the response and then using the send mediator, the message is sent back to the client.

Invoke the client as follows.

ant stockquote -Daddurl=http://localhost:9000/services/SimpleStockQuoteService -Dtrpurl=http://localhost:8280/

Back to Catalog