2

我正在从事一个涉及简单 Web 服务的项目,并且遇到了许多 问题。它是一个 Apache CXF 网络服务(使用 JAX-WS,通过 SOAP)。服务本身非常简单:接收请求,将请求插入数据库,并返回插入是否成功。我想依靠 XML 验证来对请求实施一些约束。

完整的 XML 验证对这个项目非常重要。到目前为止,我一直无法正确验证,尽管我的服务可以正常工作。

我很确定这一切都归结为这个错误,它阻止了验证。

Feb 8, 2010 4:47:14 PM org.apache.cxf.wsdl.EndpointReferenceUtils createSchema
WARNING: SAXException for newSchema() on 
org.xml.sax.SAXParseException: XML document structures must start and end within the same entity.
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:174)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:388)
    at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1414)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.endEntity(XMLDocumentFragmentScannerImpl.java:905)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.endEntity(XMLDocumentScannerImpl.java:605)
    at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.endEntity(XMLEntityManager.java:1393)
    at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.load(XMLEntityScanner.java:1763)
    at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.skipSpaces(XMLEntityScanner.java:1492)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanAttribute(XMLNSDocumentScannerImpl.java:442)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:277)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2755)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
    at com.sun.org.apache.xerces.internal.impl.xs.opti.SchemaParsingConfig.parse(SchemaParsingConfig.java:435)
    at com.sun.org.apache.xerces.internal.impl.xs.opti.SchemaParsingConfig.parse(SchemaParsingConfig.java:491)
    at com.sun.org.apache.xerces.internal.impl.xs.opti.SchemaDOMParser.parse(SchemaDOMParser.java:510)
    at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.getSchemaDocument(XSDHandler.java:1802)
    at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.resolveSchema(XSDHandler.java:1757)
    at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.constructTrees(XSDHandler.java:909)
    at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.parseSchema(XSDHandler.java:569)
    at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadSchema(XMLSchemaLoader.java:552)
    at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar(XMLSchemaLoader.java:519)
    at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar(XMLSchemaLoader.java:485)
    at com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory.newSchema(XMLSchemaFactory.java:210)
    at org.apache.cxf.wsdl.EndpointReferenceUtils.createSchema(EndpointReferenceUtils.java:666)
    at org.apache.cxf.wsdl.EndpointReferenceUtils.getSchema(EndpointReferenceUtils.java:690)
    at org.apache.cxf.interceptor.AbstractInDatabindingInterceptor.setSchemaInMessage(AbstractInDatabindingInterceptor.java:109)
    at org.apache.cxf.interceptor.AbstractInDatabindingInterceptor.getDataReader(AbstractInDatabindingInterceptor.java:94)
    at org.apache.cxf.interceptor.AbstractInDatabindingInterceptor.getDataReader(AbstractInDatabindingInterceptor.java:99)
    at org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLiteralInInterceptor.java:66)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:243)
    at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:109)
    at org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestination.java:98)
    at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:406)
    at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:178)
    at org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServlet.java:142)
    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:179)
    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:103)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:159)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    at java.lang.Thread.run(Thread.java:619)
Feb 8, 2010 4:47:14 PM org.apache.cxf.wsdl.EndpointReferenceUtils createSchema
WARNING: Schema for: http://myproject.com/ws/schema
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:ns1="http://myproject.com/Schema.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://myproject.com/ws/schema" version="1.0">
<xs:import namespace="http://myproject.com/Schema.xsd"/>
<xs:element name="InvalidDataFault" type="xs:string"/>
<xs:element name="RequestHeader">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="UserID" type="xs:string"/>
                <xs:element name="Password" type="xs:string"/>
                <xs:element name="CourtID" type="xs:positiveInteger"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
<xs:element name="SecurityFault">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="user" type="xs:string"/>
                <xs:element name="court" type="xs:string"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
<xs:element name="uploadData">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="ns1:DataPackage"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
<xs:element name="uploadDataResponse" type="xs:anyType"/>
</xs:schema>

有人有想法么?

4

1 回答 1

1

Any chance you can try with the latest CXF snapshots? There was a bug in this area that was fixed last week related to creating schemas for validation from relatively large schemas. The fix for that may solve this as well.

于 2010-02-09T01:55:55.363 回答