Contact Us 1-800-596-4880

Property Transformer Reference

Use a property transformer to set, remove, or copy properties on the outbound scope of a message. This transformer "transforms" only outbound properties. Note that you cannot manipulate inbound scope properties, as those are automatically generated by the message source.

The property transformer differs from the variable transformer and the session variable transformer. Refer to the table below for a comparison of these three transformers.

Property Transformer Variable Transformer Session Variable Transformer

Use

Use to set, remove, or copy properties on the outbound scope of a message.

Use to set or remove a variable on the message, tied to the current flow.

Use to set or remove a variable that is tied to the current message for its entire lifecycle, across multiple flows, applications, and even servers.

Persistence

Once a message hits an outbound-endpoint, all properties in the outbound scope are sent with the message, in the form of transport-specific metadata (HTTP headers for an HTTP outbound-endpoint, for example).

Variables set with a variable transformer persist only for the current flow and cannot cross the transport barrier.

Session variables set with a session variable transformer persist for the entire message lifecycle, regardless of transport barriers.

Configuration

STUDIO Visual Editor

Studio_PropertiesTransformerPPP
Field Value Description XML

Display Name

Property

Customize to display a unique name for the transformer in your application.

doc:name="Property"

Operation

Set Property

Select to set a new property on the outbound scope of your message (as shown in example above).

<set-property

Remove Property

Select to delete an existing property from your message to remove it from the outbound scope.

<remove-property>

Copy Properties

Select to copy an existing property from the inbound scope onto the outbound scope of your message.

<copy-properties>

Name

String or Mule Expression

Specify the name for the property that you are creating, or identify the name of the property that you are copying or removing. If you are copying or removing properties, this field accepts a wildcard "*" character.

propertyName="MyNewPropertyName"

Value

String or Mule Expression

This field displays only if you are setting a new property. Specify the value using either a string or a Mule expression, as shown in the example screenshot above.

value="MyNewPropertyValue"

XML Editor or Standalone

#Set property

<set-property propertyName="Authorization"  doc:name="Set Authentication Header" value="#[&quot;Basic &quot; + Base64.encodeBase64String(&quot;username:password&quot;)]"/>


# Remove property

<remove-property propertyName="PropertyForRemoval" doc:name="Delete Property"/>


# Copy property

<copy-properties propertyName="http.*" doc:name="Copy All HTTP Headers"/>
Element Description

set-property

Set a new property on the outbound scope of your message (as shown in example below).

remove-property

Delete an existing property from your message to remove it from the outbound scope.

copy-properties

Copy an existing property from the inbound scope onto the outbound scope of your message

Element Attribute Description

doc:name

Customize to display a unique name for the transformer in your application, as shown in the example below.

Note: Attribute not required in Mule Standalone configuration.

propertyName

The name of the property that you are setting, copying, or removing. Can be a string or a Mule expression.

Note: If you are using the remove-property or copy-properties element, you may use a wildcard "*"character. For example, a copy-properties transformer with a property name "http." will copy all properties whose names begin with "http.", from the inbound scope to the outbound scope.

value

The value of the property that you are setting. This attribute is only relevant for the set-property element. Can be a string or a Mule expression.

Example

In the example below, we want to connect to a web service protected by an HTTP basic authentication mechanism. In order to do that, our HTTP request needs to include a header, Authorization, which contains the username and password that allows the request go through. The properties transformer shown below sets an outbound property named Authorization and applies the value that is required to authenticate the message. The HTTP transport turns this outbound property into an HTTP header.

STUDIO Visual Editor

Studio_PropertyTransformer

XML Editor or Standalone

<flow name="PropertyTransformingFlow" doc:name="PropertyTransformingFlow">
   <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" doc:name="HTTP"/>
      <set-property propertyName="Authorization"  doc:name="Set Authentication Header" value="#[&quot;Basic &quot; + Base64.encodeBase64String(&quot;username:password&quot;)]"/>
   <http:outbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" method="POST" doc:name="HTTP"/>
</flow>

Complete Code Example

Namespace
<mule 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.4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="

http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd 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">
Body
<flow name="PropertyTransformingFlow" doc:name="PropertyTransformingFlow">
   <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" doc:name="HTTP"/>
      <set-property propertyName="Authorization"  doc:name="Set Authentication Header" value="#[&quot;Basic &quot; + Base64.encodeBase64String(&quot;username:password&quot;)]"/>
      <remove-property propertyName="PropertyForRemoval" doc:name="Delete Property"/>
      <copy-properties propertyName="http.*" doc:name="Copy All HTTP Headers"/>
   <http:outbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" method="POST" doc:name="HTTP"/>
</flow>

See Also