I'm looking for suggestions on how best to approach a problem. I'm currently working on a project where we are using CXF to expose REST services which will be consumed both by direct service consumers as well as a co-developed spring MVC/javascript based application.
I suspect that we are doing fairly typical stuff in that we are annotating our services to produce both xml and json (driven by jaxb annotations), and this is working fine for simple marshaling. However I now have the need to also handle some fairly simple transformations (omitting and renaming elements) both coming in and out of a particular service. The reason for the transformation is that I essentially have a POJO that represents somewhat of a "union of types", and I have no compelling reason to realize this "union" as a class hierarchy, other than to make the service interface "clean" (the underlying business service prefers to operate on this "union" as does the data access layer). More or less, I am trying to avoid creating DTOs, or rather I am attempting to realize the DTO's only through XML transformation. So, I would like to provide a simple set of rules (xslt) to do the transformation for both XML and json output, but that is where I am not conceptualizing the simple solution. XSLTJaxbProvider seems to be very close to what I want (and indeed I have been able to get this to work for marshaling XML), but I'm not sure how to extend this approach to also work for JSON transformations without having to write two XSLT's (one for handling XML and the other for handling json). Am I thinking about the problem wrong, i.e. two templates is the way to handle this (regardless of the maintenance overhead), and/or I should just stop being lazy and implement the darn POJO's (again irrespective of the maintenance overhead) ... If I am on the right track but some sample code would be helpful in seeing where I am going astray, I can provide that as well ... Any suggestions/revelations would be greatly appreciated. -- View this message in context: http://cxf.547215.n5.nabble.com/XSLTJaxbProvider-and-json-tp4632954p4632954.html Sent from the cxf-dev mailing list archive at Nabble.com.
