Yes, that's as far as I got but I can't make the catalog/resolver work... Xerces doesn't seem to call the one set on the SchemaFactory.
(Isn't there something in CXF I can copy? It must validate a SOAP message against a WSDL somewhere..?) -----Original Message----- From: Daniel Kulp [mailto:[email protected]] Sent: 25 April 2012 16:32 To: [email protected] Cc: John Baker Subject: Re: CXF, JMS/AMQP listener On Wednesday, April 25, 2012 03:16:43 PM John Baker wrote: > That's the problem, I'm not using an endpoint. > > I'm reading a message from AMQP, pulling out the body and passing to JAXB. > However, the body has WSDL namespaces so I can't let JAXB validate it > because it doesn't know what to do with a WSDL. > > I've spent some time looking at this and a number of other people are > asking the same question on various forums: Surely it's possible to > validate a raw SOAP message against a WSDL? But it doesn't seem to be > so easy. > > I've got as far as pulling out the schema from the WSDL and using a > schema validator, but I can't make schema catalogs work with Xerces. > > Is there a solution to this in CXF? With the advent of AMQP, I'd > expect more people to be pulling messages from RabbitMQ/etc, passing > through Spring integrate and wanting to validate them. If that's all you are doing, I'd recommend just using the javax.xml.validation.* stuff and avoid the JAXB stuff entirely. Basically, if would fall into the steps: 1) Collect all the schemas that you need. You will need them as streams (or readers). DOM's don't work here. :-( 2) Write a org.w3c.dom.ls.LSResourceResolver that can return those. 3) Call something like: SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); factory.setResourceResolver(new SchemaLSResourceResolver(..)); schema = factory.newSchema(schemas); to create the schema. 4) Validate with: schema.newValidator().validate(new DOMSource(msg)); The tricky part is obviously #2. You can look in our code for a starting point: http://svn.apache.org/repos/asf/cxf/trunk/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java The LSResourceResolver can use catalogs or whatever to resolve the schemas. Dan > > > > -----Original Message----- > From: Daniel Kulp [mailto:[email protected]] > Sent: 25 April 2012 16:13 > To: [email protected] > Cc: John Baker > Subject: Re: CXF, JMS/AMQP listener > > On Wednesday, April 25, 2012 11:10:36 AM John Baker wrote: > > I've done that but I'm now missing a SOAP message validation step. > > Jaxb2marshaller can't do this even if I pull out the body as the > > namespaces refer to the WSDL. > > > > Is there a CXF component to validate a SOAP message against a WSDL? > > Actually, the JAXB Marshaller/Unmarshaller can do this if you turn it on. > By default, we don't have it turned on due to performance impact. > However, if you add a property of "schema-validation-enabled" with a > value of "true" to the endpoint, then CXF will setup the JAXB > (un)marshaller to validate the incoming XML against the wsdl/schema. > > Dan > > > -----Original Message----- > > From: Alex O'Ree [mailto:[email protected]] > > Sent: 25 April 2012 12:09 > > To: [email protected] > > Subject: Re: CXF, JMS/AMQP listener > > > > You could setup a subscriber, then create a jaxb marshaller and > > attempt to convert it to the expected data type. I don't recall > > seeing anything built in though, maybe someone else has On Wed, Apr > > 25, 2012 at 6:00 AM, John Baker > > <[email protected]> wrote: > > > Hello > > > > > > Is there a CXF component to connect to a JMS or AMQP queue, read > > > messages and validate the SOAP message against the WSDL etc? > > > > > > > > > John > > > > > > > > > ****************************************************************** > > > ** > > > ** > > > ******** The information contained in this email may be confidential. > > > It is intended only for the use of the named recipient. If you are > > > not the named recipient please delete this email and notify the > > > sender of the delivery error. If you have received this email and > > > are not the named recipient, any disclosure, reproduction, > > > distribution or other dissemination or use of the information > > > contained in this email is strictly prohibited. > > > > > > The transmission of email cannot be guaranteed to be secure or > > > error free as information could be intercepted, corrupted, lost, > > > destroyed, arrive late or incomplete, or contain viruses. The > > > sender therefore does not accept liability for any errors or > > > omissions in the contents of this message which arise as a result > > > of email transmission. If verification is required please request > > > a hard copy version. > > > > > > The Camelot group of companies includes: > > > Camelot UK Lotteries Limited (reg. no 2822203), Camelot Business > > > Solutions Limited (reg. no 07553982), Camelot Strategic Solutions > > > Limited (reg. no 07553980), Camelot Global Services Limited (reg. > > > no > > > 02822300) and Camelot Commercial Services Limited (reg. no > > > 06911097), all of which are registered in England and Wales and > > > have their registered office at: Tolpits Lane Watford > > > WD18 9RN > > > Tel : 01923 425000 > > > ****************************************************************** > > > ** > > > ** > > > ******** > > -- > Daniel Kulp > [email protected] - http://dankulp.com/blog Talend Community Coder - > http://coders.talend.com -- Daniel Kulp [email protected] - http://dankulp.com/blog Talend Community Coder - http://coders.talend.com
