Skip to content

Injecting Messages to a RESTful Endpoint

In order to use the Message Injector to inject messages to a RESTful endpint, you can specify the injector with the required payload and inject the message to the sequence or proxy service as defined below. The sample below shows a RESTful message injection through a proxy service.

Synapse configurations

Following are the integration artifacts that we can used to implement this scenario. See the instructions on how to build and run this example.

<task class="org.apache.synapse.startup.tasks.MessageInjector" group="synapse.simple.quartz" name="SampleInjectToProxyTask" xmlns="">
    <trigger count="2" interval="5"/>
    <property name="injectTo" value="proxy" xmlns:task=""/>
    <property name="message" xmlns:task="">
        <request xmlns="">
    <property name="proxyName" value="SampleProxy" xmlns:task=""/>
<?xml version="1.0" encoding="UTF-8"?>
<proxy name="SampleProxy" startOnLoad="true" transports="http https" xmlns="">
            <property expression="//request/location/city" name="" scope="default" type="STRING"/>
            <property expression="//request/location/country" name="" scope="default" type="STRING"/>
                <property expression="get-property('')" name="Which city?"/>
                <property expression="get-property('')" name="Which country?"/>
                <endpoint name="EP">
                    <http method="get" uri-template="{},{}&amp;APPID=ae2a70399cf2c35940a6538f38fee3d3"/>
            <log level="full"/>

Build and run

Create the artifacts:

  1. Set up WSO2 Integration Studio.
  2. Create an integration project with an ESB Configs module and an Composite Exporter.
  3. Create the proxy service and a scheduled task with the configurations given above.
  4. Deploy the artifacts in your Micro Integrator.

The XML message you injected (i.e., This is a scheduled task of the default implementation.) will be printed in the logs of the Micro Integrator twice, 5 seconds apart.

INFO {org.apache.synapse.mediators.builtin.LogMediator} - Which city? = London, Which country? = UK