I am using a RestDataSource and the POSTMESSAGE protocol to fetch and update data in a datasource. The result on the fetch is nested XML for which I use the XPath support to select a nested value. This all works great. When I update a record in the datasource (with bounded form) it sends the update operation in XML. On the server side I will deserialize this into a java object and perform a save through Hibernate. But the XML for the update is different from the fetch result. This is due to the XPath value, which is returned as a property on the record level instead of the nested XML. Based on the xpath value it should be possible to reconstruct the original structure. Actually the datasource keeps the nested xml and sends it also back to the server on the update. See below for an example:
The response on the fetch request:
<response>
<status>0</status>
<startRow>0</startRow>
<endRow>2</endRow>
<totalRows>2</totalRows>
<data>
<item>
<id>1</id>
<name>Item 1</name>
<itemType>
<id>1</id>
<name>ItemType 1</name>
</itemType>
</item>
.....
</data>
</response>
The update sends the following request:
<request>
<data>
<item>
<id>1</id>
<code>Item 1</code>
<itemTypeID>2</itemTypeID>
<itemType>
<id>1</id>
<name>ItemType 1</name>
</itemType>
</item>
</data>
<oldValues>
.....
</oldValues>
<dataSource>item</dataSource>
<operationType>update</operationType>
</request>
Note the “itemTypeID” that is added which is the name of the datasourcefield that uses the following simple Xpath expression: “itemType/id”. From data integration point of view I think it would be very useful if the framework would make sure that the resulting XML data would be directly useable on the backend. And with the xpath it should be possible to reconstruct the data?
Maybe there is something I am overlooking to tell the datasource to manage this. I have also tried to override the transformRequest method (in order to change it programmatically but this method is never called (see other post). Please let me know whether this is possible at all, otherwise I need to implement some custom transformation on the server side.