On Fri, Dec 31, 2010 at 10:54 AM, jcaristi <[email protected]>wrote:
> We are using JiBX CodeGen to go from XML schema to Java for Axis2 web
> services. We code our XSD files with the appropriate constraints on each
> field. However, we are doing all of our request validation on the server
> side in Java. We want our validation logic to be executed in the business
> tier so we can provide precise, contextual, localized error coding and
> error
> messages on the response. For this we are using the Spring Validator
> framework, which really simplifies the task.
>
> One problem with this approach is that we have to code the constraints
> twice, once in the XSD and once in Java. This means that we also have to
> keep them in sync, which is hard. Now that Spring supports JSR-303, we
> could eliminate the Java coding of basic validation by using annotations on
> our entity classes (example below). If these could be derived from our XML
> schema, it would be great!
>
I have a somewhat contrarian view, but IMHO this is a good example of why
XSD documents are basically useless. Invariably XML documents require
programmatic, runtime validation beyond what XSD provides. As I understand
things SOAP requires them; for me, that's a good reason to avoid SOAP (not
to mention most other products of Microsoft).
The pattern I end up following is: start with Java classes with JSR 303
annotations (including custom validators as necessary), create the
corresponding JiBX bindings, and validate at runtime simply by (a)
processing through JiBX and (b) running the result through the validator. If
it passes (a) and (b), you've got something that will work. Moreover,
there's no validation that can't be verified by some combination of (a) and
(b).
-Archie
--
Archie L. Cobbs
------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand
malware threats, the impact they can have on your business, and how you
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users