Ben Mathews
Ben Mathews

Reputation: 2998

Have mule call http process that expects multipart/form-data

I have a backend process that expects multipart/form-data. I'd like to have mule call it and return the results. Here is a simple flow that I've worked up. However, the outbound-endpoint doesn't transform the message into multipart/form-data. The backend process just gets the body that was initially posted in.

What am I doing wrong?

<flow name="testFlow">
    <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" mimeType="text/plain" contentType="text/plain" />
    <message-properties-transformer>
        <add-message-property key="f" value="#[payload:java.lang.String]"/>
    </message-properties-transformer>
    <http:outbound-endpoint exchange-pattern="request-response" host="x12backend" port="9877" path="dummy.php" contentType="multipart/form-data"/>
</flow>

Upvotes: 1

Views: 1360

Answers (1)

David Dossot
David Dossot

Reputation: 33413

Only messages with attachments are automatically turned into multipart request entities so the best for you would be to:

  • Move the message payload to an outbound attachment: the attachment name will be used for the part name. Use the set-attachment and set-payload message processors or a Groovy transformer for that.
  • Set the message payload to org.mule.transport.NullPayload (with set-payload and a #[null] expression, otherwise it'll be posted a second time in a part named "payload".

Upvotes: 2

Related Questions