Sep 29th, 2008, 04:13 AM
How can I populate default attributes and elements when validating?
I have a scenario where I have a single end point, but multiple XSDs (multiple WSDLs). I have a transforming interceptor which transforms the requests to conform to a generic XSD, and the requests are then marshalled using JAXB.
I have used the XSD "fixed" attribute for elements and attributes that are "givens" in the context of the specific XSD - in order to remove the need for the user/client code to have to specify certain things that remain constant.
I am testing my web services using a web application written in Visual Studio (2003). Unfortunately Visual Studio refuses to serialize default attributes and elements, which is quite understandable - the assumption seems to be that any end point will "know" what any fixed attributes or elements are.
The difficulty is that my single end point is written to handle a single JAXB request object. I believe that generated JAXB classes are able to default attribues and elements that are marked as "fixed". However I cannot utilise this because my JAXB classes are generated from my generic XSD.
Assuming (for now) that multiple end points, and therefore multiple sets of generated JAXB marshalling classes, are not an option for me, is there any way I can auto-populate defaulted attributes and elements (i.e. fixed="true" use="required")?
I already have an PayloadValidatingInterceptor which is used to validate the request against the specific XSDs prior to the transformation.
Is there a way I can populate these values as part of the validation (a "validation builder" I think is generally what people call this)? Ideally I would be able to set a property on my PayloadValidatingInterceptor bean of
<property name="populateFixedValues" value="true"/>
I would like to avoid having to write a separate interceptor which also has to parse the XML and XSD to populate these.
Tags for this Thread