开发者

CXF - JAX-WS server side Schema Validation does not find element definition

I have a web service that defines severals schemas in the webTypes section. I define a read operation which type is define in this schema:

<xs:schema version="1.0" targetNamespace="http://example.com/webservice/service" xmlns:ns0="http://example.com/webservice/parameter" xmlns:xs="http://www.w3.org/2001/XMLSchema">
     <xs:import namespace="http://example.com/webservice/parameter"/>
     <xs:complexType name="read">
        <xs:sequence>
           <xs:element name="name" type="xs:string" minOccurs="1" maxOccurs="1" />
           <xs:element name="filter" type="ns0:filter" minOccurs="0" maxOccurs="1"/>
           <xs:element name="startIndex" type="xs:int" minOccurs="1" maxOccurs="1" />
           <xs:element name="noOfResults" type="xs:int" minOccurs="1" maxOccurs="1" />
        </xs:sequence>
     </xs:complexType>
     <xs:element name="read" type="tns:read"/>
  </xs:schema>

Then I activate the schema validation in the CXF config file开发者_如何学运维 like this:

<jaxws:endpoint id="dataService" 
                implementor="com.example.webservice.jaxws.endpoint.SIB"
                address="/DataService"
                wsdlLocation="classpath:DataService.wsdl">
                <jaxws:properties>
                    <entry key="schema-validation-enabled" value="true" />
                </jaxws:properties>
</jaxws:endpoint>

I tested my schema validating some of my request with the SOAPUI validator, and it works perfectly. But in the server side, when a request is received I'm getting this error:

Caused by: javax.xml.bind.UnmarshalException
  - with linked exception:
 [org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'name'.]
     at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(UnmarshallerImpl.java:425)
     at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:362)
     at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:339)
     at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:768)
     ... 287 more
Caused by: org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'name'.
     at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
     at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
     at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
     at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
     at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
     at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)
     at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown Source)
     at org.apache.xerces.jaxp.validation.ValidatorHandlerImpl.startElement(Unknown Source)
     at com.sun.xml.bind.v2.runtime.unmarshaller.ValidatingUnmarshaller.startElement(ValidatingUnmarshaller.java:96)
     at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.handleStartElement(StAXStreamConnector.java:242)
     at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StAXStreamConnector.java:176)
     at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:360)
     ... 289 more

Any Clue? It seems that the validator can access the "read" operation definition. I don't know what to do because actually the webservices works correctly without the schema validation, but I want to avoid param validation in the web services implementation.

Thanks in advance,

NOTE I'm Using CXF 2.3.3 with JAXWS 2.2 and JAXB 2.2.1 in a non endorsed tomcat 6 with java 1.6.0.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜