cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Kulp <dk...@apache.org>
Subject Re: Generated Java client from WSDL: request omits required element
Date Thu, 29 Mar 2012 20:55:58 GMT
On Thursday, March 29, 2012 10:51:56 AM Jesse Klaasse wrote:
> I have generated a Java client from an existing WSDL. Part of the WSDL
> is:
>
> <xsd:element name="Patients" type="tns:TableOfBapi1084srch"/>
> 
> Which resulted in this piece of code:
> 
> @XmlElement(name = "Patients", required = true)
> 
> protected TableOfBapi1084Srch patients;
> 
> As you probably already assume from the "TableOfBapi1084srch" name,
> "Patients" is a container element which is reflected by an (Array)List
> in Java. All is fine so far.
> 
> However, when this list is empty, the "Patients" element does not occur
> in the request (checked with Wireshark), and thus (since the "Patients"
> element is required) the web service reponse is not as expected.
> 
> To me, this feels as a bug, and, more important, I don't have any clues
> how to fix this behavior. Any ideas/suggestions?

This is more of a JAXB thing, but....

The required=true stuff is really just used for two things:

1) If generating a schema (java first cases), it marks it minOccurs=1 
instead of 0.  

2) To let YOU the developer know you need to put something there.

JAXB, by default, will not really look at that at runtime.   If data is 
there, it writes it, if not, it doesn't.    The only thing you can really do 
is turn on schema-validation which will do a complete validation of the xml 
against the schema.


-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com


Mime
View raw message