Mule XStream XML to Object

67 views Asked by At

I have this xml format that must be converted via Mule XML to Object component. Using xStream.

<server session="1234" time="2014-01-01T00:00:00">
    <getbalance id="101" guid="X9HK3G898NYML5B5" />
</server>

And the alias class

public class Server {   
    private String session;
    private Date time;
    // getters and setters
}

mule xml

...
<mulexml:xml-to-object-transformer doc:name="XML to Object">
    <mulexml:alias name="server" class="ps.Server"/>
</mulexml:xml-to-object-transformer>
...

when simulating the request i got null

Server [session=null, time=null]

how to get session="1234" time="2014-01-01T00:00:00" from the root node?

1

There are 1 answers

0
Nuno On

Try creating the server class like this

public class Server {
    @JacksonXmlProperty(isAttribute = true)
    private String session;
    @JacksonXmlProperty(isAttribute = true)
    private Date time;
    // getters and setters
}

Hope it helps