Oliver Kohll
Oliver Kohll

Reputation: 790

Posting HTTP parameters with Mule using polling

First time using Mule. I have the flow listed below, which is trying to post parameters to a URL every 15 seconds.

I gather that the URL parameters have to be defined as a payload, like

Mule ESB - How to call a API via HTTP POST method (sending parameters along)

<set-payload value="#[['xxx':'yyy']]"/>

but I can't find out where to place this, when using a poll element as below. The error I get with it in it's current position is

Invalid content was found starting with element 'poll'.

I've tried before the poll, inside it and inside http:outbound-endpoint. Any ideas?

Thanks Oliver

<mule xmlns:smtp="http://www.mulesoft.org/schema/mule/smtp" xmlns:email="http://www.mulesoft.org/schema/mule/email" xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
    xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.5.2"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd
http://www.mulesoft.org/schema/mule/smtp http://www.mulesoft.org/schema/mule/smtp/current/mule-smtp.xsd
http://www.mulesoft.org/schema/mule/email http://www.mulesoft.org/schema/mule/email/current/mule-email.xsd">
    <message-properties-transformer name="Message_Properties" doc:name="Message Properties">
        <add-message-property key="Authorization" value="mykey"/>
    </message-properties-transformer>
    <flow name="testFlow2" doc:name="testFlow2">
    <set-payload doc:name="Set Payload" value="#[['test':'test']]"/>
        <poll doc:name="Poll">
            <fixed-frequency-scheduler frequency="15" timeUnit="SECONDS"/>
            <http:outbound-endpoint exchange-pattern="request-response" method="POST" address="http://myurl.com" doc:name="HTTP" transformer-refs="Message_Properties">
            </http:outbound-endpoint>
        </poll>
        <logger level="INFO" doc:name="Logger"/>
    </flow>
</mule>    

Upvotes: 0

Views: 445

Answers (1)

Ryan Carter
Ryan Carter

Reputation: 11606

You need to set the payload before the outbound-endpoint. However the poll only excepts one message processor so they need to be shoe-horned using processor-chain or a sub-flow or similar:

<poll doc:name="Poll">
            <fixed-frequency-scheduler frequency="15"
                timeUnit="SECONDS" />
            <processor-chain>
                <set-payload value="#[['xxx':'yyy']]" />
                <http:outbound-endpoint exchange-pattern="request-response"
                    method="POST" address="http://myurl.com" doc:name="HTTP"
                    transformer-refs="Message_Properties">
                </http:outbound-endpoint>
            </processor-chain>
        </poll>

Upvotes: 1

Related Questions