You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Anthony Webster <an...@transcendenz.co.uk> on 2011/06/20 21:17:38 UTC
nillable? required?
Hi,
Here's a quick (hopefully) question. Is it possible to ensure that function
parameters are always non-null? It would be cool if I didn't have to perform
a whole bunch of checks on the server-side and just assume that incoming
requests don't contain null arguments (at least in cases where null values
make no sense - addContact(null) or whatever). I assumed that putting an
@XmlElement(required = true, nillable = false) on my business objects would
do the trick but I can still pass null arguments using my CXF test rig and
they go straight through to the server-side method implementation.
Maybe I'm missing the point somewhere...
Any ideas?
Much obliged,
Anthony
Re: nillable? required?
Posted by Daniel Kulp <dk...@apache.org>.
On Monday, June 20, 2011 9:17:38 PM Anthony Webster wrote:
> Hi,
>
> Here's a quick (hopefully) question. Is it possible to ensure that function
> parameters are always non-null? It would be cool if I didn't have to perform
> a whole bunch of checks on the server-side and just assume that incoming
> requests don't contain null arguments (at least in cases where null values
> make no sense - addContact(null) or whatever). I assumed that putting an
> @XmlElement(required = true, nillable = false) on my business objects would
> do the trick but I can still pass null arguments using my CXF test rig and
> they go straight through to the server-side method implementation.
>
> Maybe I'm missing the point somewhere...
>
> Any ideas?
JAXB, by default, doesn't do any schema validation. The
nillable=false/required=true stuff really just affects the schema that is
generated. If you want to enforce that stuff, you would need to turn on the
schema validation.
--
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog
Talend - http://www.talend.com
Re: nillable? required?
Posted by Glen Mazza <gm...@talend.com>.
AFAIK all nillable=false prevents is your ability to add the xsi:nil
attribute to the element in question. You can still send elements
without any content, nillable or not. Perhaps you can set a minimum
length for content in particular fields, and activate schema validation
(http://www.jroller.com/gmazza/entry/soap_xml_schema_validation) to
accomplish what you're looking for.
HTH,
Glen
On 06/20/2011 03:17 PM, Anthony Webster wrote:
> Hi,
>
> Here's a quick (hopefully) question. Is it possible to ensure that function
> parameters are always non-null? It would be cool if I didn't have to perform
> a whole bunch of checks on the server-side and just assume that incoming
> requests don't contain null arguments (at least in cases where null values
> make no sense - addContact(null) or whatever). I assumed that putting an
> @XmlElement(required = true, nillable = false) on my business objects would
> do the trick but I can still pass null arguments using my CXF test rig and
> they go straight through to the server-side method implementation.
>
> Maybe I'm missing the point somewhere...
>
> Any ideas?
>
> Much obliged,
>
> Anthony
--
Glen Mazza
Application Integration Division
Talend (http://www.talend.com/ai)
blog: http://www.jroller.com/gmazza