9 Replies Latest reply: Nov 12, 2010 4:26 AM by andreas_back RSS

Schema Validation - Failed to read schema document

Bob Bucy Newbie

Trying to turn on Schema Validation for a webservice I have created. All is ok running without validation, wsconsume has no issues generating artifacts on the server side, nor any issues running wsconsume on client side, nor any issue running the client and getting a response from the server when schema validation is NOT enabled. But, as soon as I turn on schema validation, I get the following error on the server.

17:03:59,347 INFO [SOAPBodyElementDoc] Validating: XML_VALID
17:03:59,363 WARN [StrictlyValidErrorHandler] org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document 'OneCardTxnRequest.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
17:03:59,363 WARN [StrictlyValidErrorHandler] org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document 'OneCardTxnResponse.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
17:03:59,363 ERROR [StrictlyValidErrorHandler] org.xml.sax.SAXParseException: src-resolve: Cannot resolve the name 'ocreq:OCReq' to a(n) 'element declaration' component.
17:03:59,363 ERROR [SOAPFaultHelperJAXWS] SOAP request exception
org.jboss.ws.WSException: org.xml.sax.SAXException: src-resolve: Cannot resolve the name 'ocreq:OCReq' to a(n) 'element declaration' component.
at org.jboss.ws.WSException.rethrow(WSException.java:68)
at org.jboss.ws.core.soap.SOAPBodyElementDoc.validatePayload(SOAPBodyElementDoc.java:130)
at org.jboss.ws.core.soap.SOAPBodyElementDoc.transitionTo(SOAPBodyElementDoc.java:82)
at org.jboss.ws.core.soap.SOAPContentElement.getObjectValue(SOAPContentElement.java:173)
at org.jboss.ws.core.EndpointInvocation.transformPayloadValue(EndpointInvocation.java:263)
........

My wsdl does import two xml schemas that represent the request and response documents. Actually, had this as a single schema, but thought I'd break it up too see if the issue was dealing with both elements. Anways, a snippet of the wsdl is as follows.

<wsdl:definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:ocreq="http://request.doc.onecard.exchange.hps.com/"
xmlns:ocrsp="http://response.doc.onecard.exchange.hps.com/"
xmlns:tns="http://ws.onecard.exchange.hps.com/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
targetNamespace="http://ws.onecard.exchange.hps.com/">
<wsdl:types>
<xs:schema targetNamespace="http://ws.onecard.exchange.hps.com/" version="1.0" xmlns:tns="http://ws.onecard.exchange.hps.com/" xmlns:ocreq="http://request.doc.onecard.exchange.hps.com/" xmlns:ocrsp="http://response.doc.onecard.exchange.hps.com/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:import schemaLocation="OneCardTxnRequest.xsd" namespace="http://request.doc.onecard.exchange.hps.com/"/>
<xs:import schemaLocation="OneCardTxnResponse.xsd" namespace="http://response.doc.onecard.exchange.hps.com/"/>
<xs:element name="doTransaction" type="tns:doTransaction"/>
<xs:element name="doTransactionResponse" type="tns:doTransactionResponse"/>
<xs:complexType name="doTransaction">
<xs:sequence>
<xs:element minOccurs="0" ref="ocreq:OCReq"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="doTransactionResponse">
<xs:sequence>
<xs:element minOccurs="0" ref="ocrsp:OCRsp"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
</wsdl:types>
.................
</wsdl:definitions>

And a snippet of my Service implementation class is as follows.

@WebService(serviceName="OneCardService", portName = "OneCardInterface", endpointInterface="com.hps.exchange.onecard.ws.OneCardInterfaceType",
targetNamespace = "http://ws.onecard.exchange.hps.com/", wsdlLocation = "WEB-INF/wsdl/OneCard.wsdl" )
@SchemaValidation
public class OneCardInterface extends SpringBeanAutowiringSupport implements OneCardInterfaceType
{
......
}

I do actually generate my artifacts using wsconsume in a different project and then copy my wsdl and the two xml schemas to my WAR's WEB-INF/wsdl directory. Not sure, if that could be effecting anything. Kind of running around in circles at this point. Any ideas would be greatly, greatly appreciated. Thanks, Bob