When you search for the usage of SchemaValidation.schemaLocation you
will find
String xsdLoc = anFeature.schemaLocation();
if (xsdLoc.length() > 0)
{
if (dep instanceof ArchiveDeployment)
{
try
{
URL xsdURL =
((ArchiveDeployment)dep).getMetaDataFileURL(xsdLoc);
xsdLoc = xsdURL.toExternalForm();
}
catch (IOException ex)
{
throw new WSException("Cannot load schema: " + xsdLoc, ex);
}
}
feature.setSchemaLocation(xsdLoc);
}
ArchiveDeployment.getMetaDataFileURL() is used for all metadata
resources that need to be loaded for an endpoint. For example the wsdl
location
String wsdlLocation = anWebServiceProvider.wsdlLocation();
if (wsdlLocation.length() > 0)
{
URL wsdlURL = dep.getMetaDataFileURL(wsdlLocation);
serviceMetaData.setWsdlLocation(wsdlURL);
}
So yes, its an resource like any other.
If the schema location is not set, the schema will be extracted from the
WSDL. There currently is an limitation that the wsdl can only contain a
single schema element.
cheers
-thomas
David Boeren wrote:
The question is:
What is the correct way to declare a @SchemaValidation annotation on an
endpoint in order to have it validate incoming XML against an xsd file
that is located within the war inside the WEB-INF directory?
Thomas Diesler wrote:
> Hi David,
>
> what is your specific question? If the documentation is not clear, you
> can easily improve it based on your understanding - I of course can
> help you to improve your understanding.
>
> cheers
> -thomas
>
> Heiko Braun wrote:
>> Do you want to take a look at this?
>>
>>
>>
>>
>> ------------------------------------------------------------------------
>>
>> Subject:
>> @SchemaValidation case
>> From:
>> David Boeren <dboeren(a)redhat.com>
>> Date:
>> Thu, 03 Apr 2008 08:26:55 -0500
>> To:
>> Heiko Braun <hbraun(a)redhat.com>
>>
>> To:
>> Heiko Braun <hbraun(a)redhat.com>
>>
>>
>> I've got a case where the customer is wanting to use
>> @SchemaValidation to validate their webservice calls, but is getting
>> errors.
>>
>>
https://enterprise.redhat.com/issue-tracker/?module=issues&action=vie...
>>
>>
>> Note: You will have to select "All Events" to see the relevant
>> information.
>>
>> When they set @SchemaValidation(enabled=true) they get this error:
>>
>> 2008-04-02 10:46:36,806 DEBUG
>> [org.jboss.ws.core.jaxws.handler.HandlerChainExecutor] Create a
>> handler executor: []
>> 2008-04-02 10:46:36,806 DEBUG
>> [org.jboss.ws.core.jaxws.handler.HandlerDelegateJAXWS]
>> callRequestHandlerChain: PRE
>> 2008-04-02 10:46:36,806 DEBUG
>> [org.jboss.ws.core.jaxws.handler.HandlerResolverImpl]
>> getHandlerChain:
>>
[
type=PRE,info=[service={http://api.prepaid.tsys.com/system/wsdl}system,po...
>>
<
http://api.prepaid.tsys.com/system/wsdl%7Dsystem,port=%7Bhttp://api.prepa...
>>
>> 2008-04-02 10:46:36,806 DEBUG
>> [org.jboss.ws.core.jaxws.handler.HandlerChainExecutor] Create a
>> handler executor:
>> [org.jboss.wsf.framework.invocation.RecordingServerHandler@6421c8]
>> 2008-04-02 10:46:36,806 DEBUG
>> [org.jboss.ws.core.jaxws.handler.HandlerChainExecutor] Enter:
>> handleIn BoundMessage
>> 2008-04-02 10:46:36,806 DEBUG
>> [org.jboss.ws.core.jaxws.handler.HandlerChainExecutor] Exit: handleIn
>> BoundMessage with status: true
>> 2008-04-02 10:46:36,806 DEBUG [org.jboss.ws.core.EndpointInvocation]
>> getRequestPayload
>> 2008-04-02 10:46:36,806 DEBUG [org.jboss.ws.core.EndpointInvocation]
>> getRequestParamValue: {http://api.prepaid.tsys.com/system/type}ping
>> <
http://api.prepaid.tsys.com/system/type%7Dping>
>> 2008-04-02 10:46:36,806 INFO
>> [org.jboss.ws.core.soap.SOAPBodyElementDoc] Validating: XML_VALID
>> 2008-04-02 10:46:36,806 WARN
>> [org.jboss.ws.extensions.validation.SchemaExtractor] Multiple schema
>> elements not supported.
>> 2008-04-02 10:46:36,806 DEBUG
>> [org.jboss.wsf.framework.DefaultSPIProvider] provide SPI 'class
>> org.jboss.wsf.spi.management.ServerConfigFactory'
>> 2008-04-02 10:46:36,806 DEBUG
>> [org.jboss.wsf.framework.DefaultSPIProvider] class
>> org.jboss.wsf.spi.management.ServerConfigFactory Implementation:
>> org.jboss.wsf.framework.management.ServerConfigFactoryImpl@17b9a1a
>> 2008-04-02 10:46:36,806 ERROR [or2008-04-02 10:46:36,806 DEBUG
>> [org.jboss.ws.core.jaxws.handler.HandlerResolverImpl]
>> getHandlerChain:
>>
[
type=ENDPOINT,info=[service={http://api.prepaid.tsys.com/system/wsdl}syst...
>>
<
http://api.prepaid.tsys.com/system/wsdl%7Dsystem,port=%7Bhttp://api.prepa...
>>
>> g.jboss.ws.extensions.validation.StrictlyValidErrorHandler]
>> org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration
>> of element 'm:ping'.
>> 2008-04-02 10:46:36,806 DEBUG
>> [org.jboss.ws.core.jaxws.handler.MessageContextJAXWS] Begin response
>> processing
>> 2008-04-02 10:46:36,806 DEBUG
>> [org.jboss.ws.core.soap.MessageContextAssociation] popMessageContext:
>> org.jboss.ws.core.jaxws.handler.SOAPMessageContextJAXWS@538db1
>> (Thread http-127.0.0.1-8080-2)
>> 2008-04-02 10:46:36,806 DEBUG
>> [org.jboss.ws.core.soap.MessageContextAssociation]
>> pushMessageContext:
>> org.jboss.ws.core.jaxws.handler.SOAPMessageContextJAXWS@ee1c42
>> (Thread http-127.0.0.1-8080-2)
>> 2008-04-02 10:46:36,806 ERROR
>> [org.jboss.ws.core.jaxws.SOAPFaultHelperJAXWS] SOAP request exception
>> org.jboss.ws.WSException: org.xml.sax.SAXException: cvc-elt.1: Cannot
>> find the declaration of element 'm:ping'.
>>
>>
>> When they add a schemaLocation like this:
>> @SchemaValidation(schemaLocation="xsd/sample.xsd"), the service fails
>> to deploy.
>>
>> The documentation on our wiki about @SchemaValidation is nearly
>> non-existant so I'm assuming that I'm probably not telling him the
>> right way to use this annotation. Can you take a quick look and let
>> me know what the proper annotation should be? Or, if his error
>> indicates a different problem source, what should we be looking at?
>>
>> Thanks!
>
--
xxxxxxxxxxxxxxxxxxxxxxxxxxxx
Thomas Diesler
Web Service Lead
JBoss, a division of Red Hat
xxxxxxxxxxxxxxxxxxxxxxxxxxxx