Sample 441: Respond Mediator - Mock a service with a proxy service

<definitions xmlns="http://ws.apache.org/ns/synapse"> <proxy name="MockService"> <target> <inSequence> <log level="full"/> <payloadFactory> <format> <m:Sample xmlns:m="http://services.samples"> <m:Response> <m:value>foo</m:value> </m:Response> </m:Sample> </format> <args/> </payloadFactory> <respond/> </inSequence> </target> </proxy> </definitions>

Objective

Demonstrate how to create a simple mock service with a proxy service using the respond mediator.

Pre-requisites

  • Start Synapse using the configuration number 441 (repository/conf/sample/synapse_sample_441.ml)
    Unix/Linux: sh synapse.sh -sample 441
    Windows: synapse.bat -sample 441

Executing the Client

Invoke the MockService proxy service with a payload. Following is how we can use curl as the client

curl -v -X POST -H "Content-type: application/xml" -d '<request>foo</request>' 'http://localhost:8280/services/MockService'

Back to Catalog