Versions Compared

Key

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

...

Table of Contents
maxLevel3
minLevel3
locationtop
styleborder:1locationtop
typeflat
separatorpipe

...

Syntax

...

Parameters available to configure the PayloadFactory mediator are as follows:

Parameter NameDescription
Payload Media-TypeThis parameter is used to specify whether the message payload should be created in JSON or XML.
Payload Format

Define Inline: If this is selected, the payload format can be defined within the PayloadFactory mediator configuration by entering it in the text field which appears. To add content to the payload, enter variables for each value you want to add using the format $n (starting with 1 and incrementing with each additional variable, i.e., $1, $2, etc.). You will then create arguments in the same order as the variables to specify each variable's actual value.

Pick from Registry: If this is selected, an existing payload format which is saved in the Registry can be selected. Click either Governance Registry or Configuration Registry as relevant to select the payload format from the resource tree.

Arguments

This section is used to add an argument that defines the actual value of each variable in the format definition. The arguments must be entered in the same order as the variables in

the format

theformat,so that the first argument defines the value for variable $1, the second argument defines the value for variable $2, etc. An argument can specify a literal string (e.g., "John") or an XPath or JSON expression that extracts the value from the content in the incoming payload.

Info
titleNote

You can configure the mediator using XML. Click switch to source view in the Mediator window.

Image Removed

Examples

...

Note

If you already know the argument is XML, to avoid the PayloadFactory mediator throwing an error when the argument value begins with an html tag, add the following attribute:

deepCheck="false"

e.g., <arg deepCheck="false" evaluator="xml" expression="ctx:variable1">

Info
titleNote

You can configure the mediator using XML. Click switch to source view in the Mediator window.

Image Added

Examples

Table of Contents
maxLevel4
minLevel4

This section provides examples of using PayloadFactory mediator to generate XML and JSON messages.

...

When the JSON stream formatter and builder are enabled, if you specify a JSON expression in the PayloadFactory mediator, you must use the evaluator attribute to specify that it is JSON. You can also use the evaluator to specify that an XPath expression is XML, or if you omit the evaluator attribute, XML is assumed by default. For example:

XML

<arg xmlns:m0=" http://sample" expression="//m0:symbol" evaluator=”xml” />

or

<arg xmlns:m0=" http://sample " expression="//m0:symbol" />

JSON <arg expression="$.user.id" evaluator="json" />

Example 3: Adding arguments

...

Code Block
languagehtml/xml
<payloadFactory media-type="xml">
      <format>
           <m:checkpriceresponse xmlns:m="http://services.samples/xsd">
      
        <m:code>$1</m:code>
      
        <m:price>$2</m:price>
    
      </m:checkpriceresponse>
 
    </format>
      <args>
      format>
<args>
    <arg expression="//m0:symbol" xmlns:m0="http://services.samples/xsd">            <arg expression="//m0:last"symbol"/>
    <arg xmlns:m0="http://services.samples/xsd">
      </arg></arg>< expression="//m0:last"/>
</args>
</payloadFactory>

Example 4: Suppressing the namespace

...