web services - Server-Side XML Validation with CXF Webservice -


I am working on an Apache CXF Web Service (on JADS-SSAP, SOAP) This service is very simple: get a request, enter a request in a database, and return to see if the join was successful I would like to rely on XML validation to apply several restrictions on the request.

So, my question is how can I return detailed verification errors to my service customer? I have configured my endpoint and started verifying the server-side.

  & lt; Jaxws: endpoint id = "some pointpoint" implementor = "# someImpl" address = "/ impl" & gt; & Lt; Jaxws: Properties & gt; & Lt ;! - This entry should enable JAXB authentication on the server-side of our web service. - & gt; & Lt; Entry key = "schema-verification-enabled" value = "true" /> & Lt; / Jaxws: Properties & gt; & Lt; / Jaxws: endpoint & gt;  

I have searched using the interceptor on the server (for example, Barine Interceptor), and in some way to hold them SAXParseExceptions and send it to the client. This approach seems a little complex , But I would have to give a line number to the client any way if I want to go with the interceptor to highlight the exceptions to their XMLs?

I do not have much experience with this technology stack, and just joining web services - any indication that you can give to me will really be appreciated.

Pre-class = "lang-java top-print-override"> package example; Import javax.xml.bind.ValidationEvent; Import javax.xml.bind.helpers.DefaultValidationEventHandler; Public class MyValidationEventHandler Extended DefaultValidationEventHandler {@Override Public Boolean Handel Event (Validation Document Event) {If (event.getSeverity () == Validation Event. WARNING} {return super.handleEvent (event); } And {new runtime exposure (events. Metmase) + "[line:" + event.getLocator (). GetLineNumber () + "]"); }}}

If you configure your endpoint to use this handler:

  & Lt; Jaxws: endpoint id = "some pointpoint" implementor = "# someImpl" address = "/ impl" & gt; & Lt; Jaxws: Properties & gt; & Lt; Entry key = "schema-verification-enabled" value = "true" /> & Lt; Entry key = "jaxb-validation-event-handler" & gt; & Lt; Bean class = "example.MyValidationEventHandler" /> & Lt; / Entry & gt; & Lt; / Jaxws: Properties & gt; & Lt; / Jaxws: endpoint & gt;  

Then you will find soap defects which look like this:

  & lt; Soap: Envelope xmlns: Soap = "http://schemas.xmlsoap.org/soap/envelope/" & gt; & Lt; Soaps: Body & gt; & Lt; Soap: defect & gt; & Lt; Faultcode & gt; Soaps: Customers & lt; / Faultcode & gt; & Lt; Fault string & gt; Unsurpassing error: no number: xyz [line: 6] & lt; / Faultstring & gt; & Lt; / Soap: defect & gt; & Lt; / Soap: Body & gt; & Lt; / Soap: Envelope & gt;  

The jaxb-validation-event-handler property was recently added to the CXF, so you have to make sure that you are using the latest version - I have it 2.2. Tested with 5.


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -