SOAPClient (SOAPUI) support for JAXB annotated POJOs
sirocchj Jul 15, 2009 4:11 AMHi,
I am going to try and explain what I mean in the topic subject and why I am asking for it by describing briefly what I am doing in my project and what I would like seeing happening. I apologise if you feel all this is unnecessary info.
1. I have a fairly complex XSD schema which I need to update frequently and which maps all objects that will even get onto the bus (via WS, FS or JMS at the mo). To avoid going nuts I use JAXB RI 2.1 to generate my pojos (using also some extensions, such as fluent api, collections setter, toString, etc)
2. Using the async continuation pattern (btw thanks to Kevin Conner for pointing that out as it turn out to be VERY useful in many of my use cases) I am exposing a synchronous (w/ failover to async, more on this after) webservice to the end user ("certify customer" is the business idea) which wraps an asyncronous JMS call to a third system (black-box to me). So, if I get a valid response on the resp Q of the third party before timeout, grand, I return it to the requestor, else I return him a fault. A note on this: in async continuation pattern the service which inits the continuation needs to be mep="OneWay" but I also need to expose this as a WS and I know it WILL have a response, so in my jboss-esb.xml I set webservice="true" inXsd="my_in.xsd" outXsd="my_out.xsd" faultXsd="my_fault.xsd", I thereby fall into https://jira.jboss.org/jira/browse/JBESB-2434. So one question might be: is this JIRA going to get closed some time? :) I believe many would fall into it if they want to adopt async continuation but need also to expose webservice for it. I patched filter code as suggested by Tom Fennelly in its comment to overcome this issue for now.
3. Up to here nothing too special, but: 3i. As responses come in, either on time or not, the ESB needs to publish them on topic AND, as there are a few systems (mainly in PHP) unable/unwilling to subscribe to JMS topic, needs to forward them via SOAP WS. 3ii. Third system might generate "certified customers" objects w/o corresponding request and these also need to be treated as in point 3i.
I am going to skip the rest of the story for your own good :)
Getting to the point:
when I get these "certified customer" objects into the ESB I use Smooks to generate an object graph, using the pojos obtained in point 1 above and I set the root obj in a map (option 1 in Programmers guide). I then use SOAPClient (SOAP-UI, not WISE) to generate SOAP message and run into what I identified as three main problems:
a. Since I have many elements in my schemas which make use of attributes, I am watching this https://jira.jboss.org/jira/browse/JBESB-2455 and hoping 4.6 gets released soon as I would rather not build SOAPUIClientService from trunk :)
b. I believe my object graph gets traversed using OGNL expressions... Since I have in my .xsd several xs:simpleType which are extensions of xs:string (or indeed xs:int or other primitive types) and have one or more required attributes attached to them, these would be mapped into objects like normal variables by JAXB (but also if I were to do this manually).
So, the only way I see it, but please correct me if I am getting it wrong, to get this dumb xml:
<outerTag> <innerTag attr="some attr">Inner tag value</innerTag> </outerTag>
using this dumb POJO
public class InnerTag { private String attr; private String value; ... //getters and setters for both }
is to override default toString method so to have
public String toString() { return value; }
right???
If I don't, I believe I would get something like
<outerTag> <innerTag attr="some attr">InnerTag@2323423{attr="some attr", value="Inner tag value"}</innerTag> </outerTag>
I don't like the idea of overriding my lovely :) JAXB-generated toString method, though, as I would definetively want to use it for the sake of clarity in my log files, etc...
c. What about <xs:choice>, minOccurs="0" and nillable="true" ?? How are these handled?? I make use of choices and minOccurs="0" and I see my element tags in the generated xml... which is something I believe should not be there to begin with. I believe someone has asked some support on this previously in this forum...
To sum up: what about supporting in SOAPClient (SOAP-UI) and relative service the use a Map populated with a JAXB annotated object graph? I believe this could make it easier for example to determine wheter variable value in point b. above is indeed the value of the element or not and if element in point c. is null wheter it should be set as xs:nil="true" or should be removed for document tree.
I hope I have not overlooked at something...
Any thoughts on this?
Kind Regards
\j
------------------------------
Julien J. P. Sirocchi
Software Engineer - Nexse
Via Adolfo Rava' 124
00142 Rome
Italy