Contact Us 1-800-596-4880

Object-to-XML Transformer Reference

Mule runtime engine version 3.8 reached its End of Life on November 16, 2021. For more information, contact your Customer Success Manager to determine how to migrate to the latest Mule version.

Use a Object-to-XML transformer to transform a Java Object to XML data using XStream.

Minimum Configuration: The name of the XStream driver class.

The Object-to-XML transformer transforms Java Object data to XML using the specified XStream driver class.

Important: Mule uses XStream 1.4.2. The XML-to-object transformer is vulnerable to CVE-2013-7285. A remote attacker can send messages to an XML-to-object transformer and can achieve remote code execution (RCE). For more information, contact MuleSoft Customer Support.

In addition to the properties common to all transformers, you can also specify class aliases and converters, as well as whether or not to accept the Mule Message.

Use the General tab to specify or browse to the XStream driver class:

object+to+XML

Check the Accept Mule Message box to have the transformer accept the Mule Message. Accepting the Mule Message means that the transformer serializes the entire Mule Message, not just the message payload. The entire Mule Message includes the payload, message properties, correlation ID, and so forth.

Use the Advanced tab to optionally configure the properties standard to all transformers, plus add or change class aliases and class converters.

Use the Aliases pane to create, edit, or delete aliases for specific classes. Similarly, use the Converters pane to create, edit, or delete class converters.

Example XML Code

Setup:

object to xml transformer
<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" xmlns:db="http://www.mulesoft.org/schema/mule/db" xmlns:vm="http://www.mulesoft.org/schema/mule/vm" 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"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="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
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/db http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd
http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/current/mule-vm.xsd
http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd">
    <http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>
    <vm:connector name="VM" validateConnections="true" doc:name="VM">
        <vm:queue-profile>
            <queue-store/>
        </vm:queue-profile>
    </vm:connector>
    <flow name="demoFlow">
        <http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>
        <mulexml:object-to-xml-transformer doc:name="Object to XML"/>
    </flow>
</mule>