You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by scarlettxu <sc...@icil.net> on 2012/08/14 16:25:53 UTC
problem with unmarshal xml to Java object when there is HashMap and
Map contains another root element
Hi Expert,
I am new to CXF and met one issue related with HashMap.
It is not the problem of unmarshal and marshal normal HashMap to normal Java
objects. I have created the XML adapter to fix this, the problem is below:
XML
* <Transaction>
<trans>newUpdate</trans>
<fields>
<entries>
<key>completedBy</key>
<value xsi:type="xs:string">icil-cs</value>
</entries>
<entries>
<key>toDoItemAction</key>
<value xsi:type="com.icil.cxf.shipment.bean.Transaction">
<Transaction xsi:type="com.icil.cxf.shipment.bean.Transaction">
<trans>updateIgnore</trans>
<fields>
<entries>
<key>from</key>
<value xsi:type="xs:string">scarlett</value>
</entries>
</fields>
</Transaction>
</value>
</entries>
</fields>
</Transaction>*
The Transaction maps to my Transaction.java class.
after convert the inner Transaction is null
*toDoItemAction=[value: null]*
I search for a day but have not found any solution, can anyone helps on
this?
--
View this message in context: http://cxf.547215.n5.nabble.com/problem-with-unmarshal-xml-to-Java-object-when-there-is-HashMap-and-Map-contains-another-root-element-tp5712502.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: problem with unmarshal xml to Java object when there is HashMap
and Map contains another root element
Posted by scarlettxu <sc...@icil.net>.
Hi Freeman,
I already have the Map Adapter class that can handle the xml like
<fields>
<entry>
<key>completedBy</key>
<value xsi:type="xs:string">scarlettxu</value>
</entry>
</fields>
But when the <value> contains nested piece of xml, then it cannot translate
to Java object
<fields>
<entry>
<key>toDoItemAction</key>
<value xsi:type="Transaction">
* <Transaction>
<trans>update</trans>
<name>ToDoItemActionTO</name>
</Transaction>*
</value>
</entry>
</fields>
--
View this message in context: http://cxf.547215.n5.nabble.com/problem-with-unmarshal-xml-to-Java-object-when-there-is-HashMap-and-Map-contains-another-root-element-tp5712502p5712600.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: problem with unmarshal xml to Java object when there is HashMap and Map contains another root element
Posted by Freeman Fang <fr...@gmail.com>.
Hi,
Please ensure you already take a look at java_first_jaxws example shipped with kit, that example demonstrates how to use adapter class to handle Map.
You can adjust that example to meet your requirement, it should be a good start for you.
Freeman
-------------
Freeman Fang
FuseSource
Email:ffang@fusesource.com
Web: fusesource.com
Twitter: freemanfang
Blog: http://freemanfang.blogspot.com
http://blog.sina.com.cn/u/1473905042
weibo: http://weibo.com/u/1473905042
On 2012-8-14, at 下午10:25, scarlettxu wrote:
> Hi Expert,
>
> I am new to CXF and met one issue related with HashMap.
> It is not the problem of unmarshal and marshal normal HashMap to normal Java
> objects. I have created the XML adapter to fix this, the problem is below:
>
> XML
>
> * <Transaction>
> <trans>newUpdate</trans>
> <fields>
> <entries>
> <key>completedBy</key>
> <value xsi:type="xs:string">icil-cs</value>
> </entries>
> <entries>
> <key>toDoItemAction</key>
> <value xsi:type="com.icil.cxf.shipment.bean.Transaction">
> <Transaction xsi:type="com.icil.cxf.shipment.bean.Transaction">
> <trans>updateIgnore</trans>
> <fields>
> <entries>
> <key>from</key>
> <value xsi:type="xs:string">scarlett</value>
> </entries>
> </fields>
> </Transaction>
> </value>
> </entries>
> </fields>
> </Transaction>*
>
>
> The Transaction maps to my Transaction.java class.
> after convert the inner Transaction is null
> *toDoItemAction=[value: null]*
>
> I search for a day but have not found any solution, can anyone helps on
> this?
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/problem-with-unmarshal-xml-to-Java-object-when-there-is-HashMap-and-Map-contains-another-root-element-tp5712502.html
> Sent from the cxf-user mailing list archive at Nabble.com.