mc.setProperty is used to create a new property, as if you were using a property broker.
If you want to add a new element inside your message, in java you can process it as if it were an XML message (for example, to get the first element:
OMElement element = (OMElement) context.getEnvelope().getBody().getFirstOMChild(); )
An example of adding a new element using javascript:
<script language="js"><![CDATA[ var payloadXML = mc.getPayloadXML(); payloadXML.appendChild(new XML(<NewPropertyName>value</NewPropertyName>)); mc.setPayloadXML(payloadXML); ]]></script>
Record the message in XML format with <log level="full"> and you will get:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Body> <jsonObject> <token>abc123</token> <usertype>ext</usertype> <request>create</request> <NewPropertyName>value</NewPropertyName> </jsonObject> </soapenv:Body> </soapenv:Envelope>
Write the message in JSON using
<log> <property name="JSON-Payload" expression="json-eval($.)"/> </log>
and you will receive: JSON-Payload = {"token":"abc123","usertype":"ext","request":"create","NewPropertyName":"value"}
source share