You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Jason Rosenberg <jr...@shopzilla.com> on 2007/08/16 05:44:43 UTC
How to generate complex type restrictions with code-first
development
Hi,
I am interested in trying to create some complex xsd types, using code first
development....
So far, I've seen how to do some things, like create enums by using the
@XmlEnum annotation, etc....
What i haven't come accross is a way to specify some of the interesting
restriction facets, like:
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="5"/>
<xs:maxLength value="8"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:whiteSpace value="replace"/>
</xs:restriction>
</xs:simpleType>
And there are several other more examples here:
http://www.w3schools.com/schema/schema_facets.asp
Are these type restrictions meant to be enforced if specified in the wsdl as
such, within JAXWS and CXF?
e.g. if I specified these types for parameters, when using wsdl first
development, and then tried to pass values that don't comply to the
restrictions, should I expect a WebFault to be thrown?
Thanks,
Jason
--
View this message in context: http://www.nabble.com/How-to-generate-complex-type-restrictions-with-code-first-development-tf4277371.html#a12174861
Sent from the cxf-user mailing list archive at Nabble.com.
Re: How to generate complex type restrictions with code-first development
Posted by Daniel Kulp <dk...@apache.org>.
On Wednesday 15 August 2007, Jason Rosenberg wrote:
> I am interested in trying to create some complex xsd types, using code
> first development....
>
> So far, I've seen how to do some things, like create enums by using
> the @XmlEnum annotation, etc....
>
> What i haven't come accross is a way to specify some of the
> interesting restriction facets, like:
I don't think JAXB support saving those things in the annotations. Most
of the facet things aren't recorded. Even things like minOccurs and
maxOccurs are not recorded.
> And there are several other more examples here:
> http://www.w3schools.com/schema/schema_facets.asp
>
> Are these type restrictions meant to be enforced if specified in the
> wsdl as such, within JAXWS and CXF?
>
> e.g. if I specified these types for parameters, when using wsdl first
> development, and then tried to pass values that don't comply to the
> restrictions, should I expect a WebFault to be thrown?
Well, yes and no. By default, CXF does not turn on schema validation as
it can be expensive. However, there is a flag that can be set on the
client/endpoint to turn on the validation if the schemas are available.
In that case, JAXB will throw an exception if you try to read/write data
that is invalid. From spring config, you can do something like:
<jaxws:endpoint
name="{http://apache.org/hello_world_soap_http}SoapPort"
wsdlLocation="wsdl/hello_world.wsdl"
createdFromAPI="true">
<jaxws:properties>
<entry key="schema-validation-enabled" value="true" />
</jaxws:properties>
</jaxws:endpoint>
which would turn on the schema validation.
--
J. Daniel Kulp
Principal Engineer
IONA
P: 781-902-8727 C: 508-380-7194
daniel.kulp@iona.com
http://www.dankulp.com/blog