2013-06-28 102 views
-1

我有接收用户定义的数据类型,包括各个领域的他们,我定义为CXF JAXB XSD问题

<xsd:simpleType name="Percentage"> 
    <xsd:restriction base="xsd:decimal"> 
     <xsd:minInclusive value="0"/> 
     <xsd:maxInclusive value="1"/> 
    </xsd:restriction> 
</xsd:simpleType> 

下面的数据类型百分比之一的Web服务是我得到一个警告,我出错的任何想法?我从SOAP UI测试Web服务,所以我认为这与我如何使用我的服务无关,要添加:我首先有一个SOAP Web服务代码CXF,用于创建XSD的数据类型,然后生成类,使用XJC。也许我需要在Java类的注释中添加一些内容来明确设置名称空间?

WARN [EndpointReferenceUtils]: SAXException for newSchema() 
org.xml.sax.SAXParseException: src-resolve.4.2: Error resolving component 'ns0:Percentage'. It was detected that 'ns0:Percentage' is in namespace 'http://www.xyz.ie/cb/projections/converter/model/common', but components from this namespace are not referenceable from schema document 'file:///C:/_dev_env_/CBProjectionsWebService/trunk/cb-projections-jetty/schema3.xsd'. If this is the incorrect namespace, perhaps the prefix of 'ns0:Percentage' needs to be changed. If this is the correct namespace, then an appropriate 'import' tag should be added to 'file:///C:/_dev_env_/CBProjectionsWebService/trunk/cb-projections-jetty/schema3.xsd'. 
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195) 
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131) 
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384) 
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318) 
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reportSchemaErr(XSDHandler.java:2541) 
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reportSchemaError(XSDHandler.java:2528) 
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.getGlobalDecl(XSDHandler.java:1387) 
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDAttributeTraverser.traverseNamedAttr(XSDAttributeTraverser.java:291) 
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDAttributeTraverser.traverseLocal(XSDAttributeTraverser.java:101) 
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDAbstractTraverser.traverseAttrsAndAttrGrps(XSDAbstractTraverser.java:610) 
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDComplexTypeTraverser.processComplexContent(XSDComplexTypeTraverser.java:1059) 
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDComplexTypeTraverser.traverseComplexTypeDecl(XSDComplexTypeTraverser.java:279) 
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDComplexTypeTraverser.traverseLocal(XSDComplexTypeTraverser.java:133) 
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDElementTraverser.traverseNamedElement(XSDElementTraverser.java:356) 
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDElementTraverser.traverseLocal(XSDElementTraverser.java:179) 
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.traverseLocalElements(XSDHandler.java:2049) 
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.parseSchema(XSDHandler.java:582) 
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:698) 
at org.apache.cxf.wsdl.EndpointReferenceUtils.getSchema(EndpointReferenceUtils.java:743) 
at org.apache.cxf.interceptor.AbstractInDatabindingInterceptor.setDataReaderValidation(AbstractInDatabindingInterceptor.java:120) 
at org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLiteralInInterceptor.java:94) 
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271) 
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121) 
at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:239) 
at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:223) 
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:203) 
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:137) 
at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:158) 
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:243) 
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:163) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:755) 
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:219) 
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:669) 
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:455) 
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137) 
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:560) 
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231) 
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1072) 
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:382) 
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193) 
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1006) 
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135) 
at org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:52) 
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116) 
at org.eclipse.jetty.server.Server.handle(Server.java:365) 
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:485) 
at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:937) 
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:998) 
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:856) 
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240) 
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82) 
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:628) 
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52) 
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608) 
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543) 
at java.lang.Thread.run(Thread.java:619) 
+0

Downvoting;问题是微不足道的,通过阅读问题中引用的错误消息很容易回答。 –

回答

2

(答案:)

的长格式你没有表现相关的代码(你的问题会更好,如果它没有),但在猜想,你的百分比类型被称为到另一个模式文档中,例如CBProjectionsWebService/trunk/cb-projections-jetty/schema3.xsd中的文档。

该模式文档包含一个名称空间声明,它将某些前缀(推测为ns0)绑定到名称空间http://www.xyz.ie/cb/projections/converter/model/common,并引用使用具有该前缀的Qname的类型(例如ns0:Percentage)。

然而,声明命名空间前缀还不够:XSD要求如果您从具有给定目标命名空间的模式文档引用不同名称空间中的组件,则必须导入该其他命名空间。所以 - 正如错误消息说 - 你需要包括模式文档中导入:

<xsd:import namespace= 
    "http://www.xyz.ie/cb/projections/converter/model/common" 
/> 

在某些情况下,你可能还需要告诉系统在哪里可以找到该命名空间的架构文档:

<xsd:import namespace= 
    "http://www.xyz.ie/cb/projections/converter/model/common" 
    schemaLocation="..." 
/> 

在一般情况下,这是一个好主意,如果你限制对验证程序的调用实际位置,或单个驱动程序文件有助于维护互操作性架构的处理器中,但很多人过上幸福富裕的生活而忽视这个规则,所以请在这个问题上做出自己的想法。

(答案:)

的缩写形式读取错误消息。

+0

百分比在另一个架构中,但未称为CBProjectionsWebService/trunk/cb-projections-jetty/schema3.xsd。 –

+1

如果我推测百分比是在schema3.xsd中声明的,那么您的评论就是关键的一点。因为我没有,我只能得出结论,你已经阅读我的答案,同样小心你阅读原始错误信息。如果您想解决问题,请阅读并理解错误消息。如果您想对答案进行有用的评论,请阅读并理解答案。 –