This documentation is for WSO2 Enterprise Integrator version 6.0.0 . View documentation for the latest release in the 6.x.x family and the latest release in the 7.x.x family.

All docs This doc

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagexml
<header name="Content-Type" scope="transport" value="multipart/form-data"/>
  <property name="messageType"
      scope="axis2"
      type="STRING"
      value="multipart/form-data"/>

Example 8: Adding a literal arguement 

The following example adds a literal arguement to the Payload Factory mediator, and sets it to true. This allows you to consider the type of the argument value as String and to stop processing it. 

Code Block
languagexml
<api xmlns="http://ws.apache.org/ns/synapse" name="payload" context="/payload">
   <resource methods="POST">
      <inSequence>
         <property name="getvalue" expression="json-eval($.hello)"/>
         <payloadFactory media-type="json">
            <format>{"newValue" : "$1"}</format>
            <args>
               <arg evaluator="xml" literal="true" expression="get-property('getvalue')"/>
            </args>
         </payloadFactory>
         <respond/>
      </inSequence>
   </resource>
</api>

Following is a sample payload (i.e., a.json file), which you can process using the above configuration.

Code Block
languagejs
titlea.json
{"hello" : "<pqr>abc</pqr>"}

You can use the below sample cURL command to send the request to the above configuration.

Code Block
languagejs
curl -d @a.json http://localhost:8280/payload -H "Content-Type: application/json" -v

You view the below output:

Code Block
languagejs
{"newValue" : "{"pqr":"abc"}"}
Info

If you do not add the literal="true" within the arguement in the Payload Factory mediator of the above configuration, you view the output as follows:

{"newValue" : "<pqr>abc</pqr>"}

Samples

The following samples demonstrate the use of the PayloadFactory mediator.

...