How to validate a instance of a class generated from JaxP?
Hello Guys! I'm more familar with XmlBeans how ever to day I thougt I could solve a enhancement-request we got; add validation to a webservice we got
In this case we have a WSDL with the XSD inline, We generate the interface classes with jaxws-maven-plugin that results a with a jar with classes and the wsdl inside. (Correct me if I'm wrong when I say that JaxWS uses JaxP?) The webservice returns a object of a class from this jar. I would like to handle the validation errors on the server side so I do not think it is suitable to just use @Schemavalidation on the webservice.
I now guess I need to: 1) extract the xsd from the wsdl into a javax.xml.validation.Schema 2) covert the xmlObject into a Node 3) perform the validation
My main headache is to understand how to solve number 1, do you guys got any clues? Of course do you see any better solution? Best regards Fredrik
Hello Arne, I would like to validate it on the server side before returning it.
We have experience that our server returns null in some cases for a element, for eg "b", see below. In the wsdl it looks something like this (bare with me if I type it wrong) <xsd:element name="a" minOccurs="0" /> <xsd:element name="b" /> <xsd:element name="c" minOccurs="0" />
By mistake the developer did not know that the default value for minOccurs is 1.
Now we are going through a integration bus called "DataPower", if I remember the name correct. The "bus" got validation-mode "on", and things started to go wrong. The integration team said that they could switch the validation-mode off, but I think it is better to change the wsdl to: ... <xsd:element name="b" minOccurs="0" /> ... and also validate it on the server and perhaps some testcases.
In some how it looks like the webservice has been able to return objects that is not valid before we went through the DataPower-gizmo. Do you got any suggestions or thoughts, Arne? Best regards Fredrik
A different approach would be to install a servlet filter that intercepts the web service calls and check the response, basically parse the XML for the object with validation against schema.
Obviously the options in case of an error are very limited.
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.