[jbossws-dev] Re: [Fwd: @SchemaValidation case]

Thomas Diesler thomas.diesler at jboss.com
Fri Apr 4 09:19:26 EDT 2008


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.

http://jbws.dyndns.org/mediawiki/index.php?title=JAX-WS_User_Guide#Schema_validation_for_incoming.2Foutgoing_messages

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 at redhat.com>
>>> Date:
>>> Thu, 03 Apr 2008 08:26:55 -0500
>>> To:
>>> Heiko Braun <hbraun at redhat.com>
>>>
>>> To:
>>> Heiko Braun <hbraun at 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=view&tid=172244&gid=1354 
>>>
>>>
>>> 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,port={http://api.prepaid.tsys.com/system/wsdl}SystemServiceImplPort,binding=http://schemas.xmlsoap.org/wsdl/soap/http 
>>> <http://api.prepaid.tsys.com/system/wsdl%7Dsystem,port=%7Bhttp://api.prepaid.tsys.com/system/wsdl%7DSystemServiceImplPort,binding=http://schemas.xmlsoap.org/wsdl/soap/http>]] 
>>>
>>> 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 at 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 at 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}system,port={http://api.prepaid.tsys.com/system/wsdl}SystemServiceImplPort,binding=http://schemas.xmlsoap.org/wsdl/soap/http 
>>> <http://api.prepaid.tsys.com/system/wsdl%7Dsystem,port=%7Bhttp://api.prepaid.tsys.com/system/wsdl%7DSystemServiceImplPort,binding=http://schemas.xmlsoap.org/wsdl/soap/http>]] 
>>>
>>> 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 at 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 at 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



More information about the jbossws-dev mailing list