Followup...

So I've got this working by reading the WSDL myself in the provider
class's constructor:


// First read WSDL
ClassLoader loader = this.getClass().getClassLoader();
InputStream wsdlFile = loader.getResourceAsStream( WSDL_NAME );
Document wsdl = org.apache.cxf.helpers.DOMUtils.readXml( wsdlFile );

// Then get schema body from WSDL -- TODO tighten up query using namespaces
String schemaQuery =
"//*[local-name()='definitions']/*[local-name()='types']/*[local-name()='schema']";
XPathExpression schemaPath = xp.compile( schemaQuery );
Node schemaNode = ( Node ) schemaPath.evaluate( wsdl, XPathConstants.NODE );

// Then compile it and store it
String language = XMLConstants.W3C_XML_SCHEMA_NS_URI;
SchemaFactory sf = SchemaFactory.newInstance( language );
DOMSource ds = new DOMSource( schemaNode );
this.schema = sf.newSchema( ds );


This lets me easily validate messages in the invoke() method, for example:


schema.newValidator().validate( domRequest );


where domRequest is the DOMSource of the message payload.

However it still seems a little inelegant to read the WSDL myself when
CXF must have a copy.

I've found the getSchema() method of the EndpointReferenceUtils class
via an old thread on here, but that requires a ServiceInfo object --
is there any way to acquire one of these for a Provider service?

Thanks,

Andrew.

2009/2/16 Andrew Clegg <and...@nervechannel.com>:
> Hi folks,
>
> From inside a Provider implementation, how can I obtain the schema of
> the service's request/response messages, short of reading the WSDL
> myself and extracting the schema from it?
>
> Thanks,
>
> Andrew.
>
> --
> :: http://biotext.org.uk/ ::
>



-- 
:: http://biotext.org.uk/ ::

Reply via email to