【问题标题】:Spring 'application-context' XSD schema read issueSpring 'application-context' XSD 模式读取问题
【发布时间】:2013-04-07 03:21:42
【问题描述】:

我在我的 spring 项目中使用 JAXWS 与服务器通信,并且在我的应用程序上下文 xml 中读取 XSD 时出错。这是应用程序上下文 -

 <?xml version="1.0" encoding="UTF-8"?>
 <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:ws="http://jax-ws.java.net/spring/core"
    xmlns:wss="http://jax-ws.java.net/spring/servlet"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

  //**error at this below line -**  **cvc-complex-type.2.4.c: The matching wildcard is   strict, but no declaration can be found for element 'wss:binding'.**
  <wss:binding url="/hello">
    <wss:service>
        <ws:service bean="#helloWs"/>
    </wss:service>
   </wss:binding>

  <!-- Web service methods -->
  <bean id="helloWs" class="com.mkyong.ws.HelloWorldWS">
    <property name="helloWorldBo" ref="HelloWorldBo" />
  </bean>

  <bean id="HelloWorldBo" class="com.mkyong.bo.impl.HelloWorldBoImpl" />

任何人都可以让我知道这个错误的原因和任何解决方案。 感谢您的帮助。!

【问题讨论】:

标签: spring xsd jax-ws


【解决方案1】:

你为什么不试试下面的xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ws="http://jax-ws.dev.java.net/spring/core"
xmlns:wss="http://jax-ws.dev.java.net/spring/servlet"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://jax-ws.dev.java.net/spring/core http://jax-ws.java.net/spring/core.xsd
http://jax-ws.dev.java.net/spring/servlet http://jax-ws.java.net/spring/servlet.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">

<wss:binding url="/hello">
<wss:service>
    <ws:service bean="#helloWs"/>
</wss:service>
</wss:binding>

<!-- Web service methods -->
<bean id="helloWs" class="com.mkyong.ws.HelloWorldWS">
<property name="helloWorldBo" ref="HelloWorldBo" />
</bean>
<bean id="HelloWorldBo" class="com.mkyong.bo.impl.HelloWorldBoImpl" /> </beans>

【讨论】:

  • 我遇到了同样的错误,所以我将您的 xml 替换到我的项目中。现在我有以下错误:来自 ServletContext 资源 [/WEB-INF/applicationContext.xml] 的 XML 文档中的第 1 行无效;嵌套异常是 org.xml.sax.SAXParseException;系统ID:jax-ws.java.net/spring/servlet.xsd;行号:1;列号:1;文件过早结束。
  • 复制粘贴可能是白色字符问题。尝试手动更新文件。
【解决方案2】:

你在你的项目中使用 spring 吗?我遇到了同样的问题,但是当我在我的 maven 依赖项中包含 spring-jaxws 时问题解决了,事实上,你可以在那个 jar 中看到 META-INF/spring. schemas 文件正在重新定义 XSD 位置:

http\://jax-ws.java.net/spring/core.xsd=spring-jax-ws-core.xsd http\://jax-ws.java.net/spring/servlet.xsd=spring-jax-ws-servlet.xsd http\://jax-ws.java.net/spring/local-transport.xsd=spring-jax-ws-local-transport.xsd

希望对你有帮助!

【讨论】:

  • 你能告诉我你为相同添加的 jar 列表吗?
猜你喜欢
  • 1970-01-01
  • 2015-03-01
  • 1970-01-01
  • 2020-10-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-08-30
相关资源
最近更新 更多