匹配通配符是严格的,但没有声明可以为元素找到“WSS:结合”

问题描述:

当运行Maven的全新安装,我得到以下错误:匹配通配符是严格的,但没有声明可以为元素找到“WSS:结合”

The matching wildcard is strict, but no declaration can be found for element 'wss:binding'

我不明白为什么这个错误出现因为它是来自https://jax-ws-commons.java.net/spring/上的示例的复制粘贴。我的依赖中也有xbean-spring v3.16。

我检查了http://jax-ws.java.net/spring/servlet.xsd一个元素绑定存在!

下面是我复制的文件/粘贴:

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:context="http://www.springframework.org/schema/context" 
    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" 
    xsi:schemaLocation=" 
    http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans-3.1.xsd 
    http://www.springframework.org/schema/context 
    http://www.springframework.org/schema/context/spring-context.xsd 
    http://jax-ws.java.net/spring/core 
    http://jax-ws.java.net/spring/core.xsd 
    http://jax-ws.java.net/spring/servlet 
    http://jax-ws.java.net/spring/servlet.xsd"> 

    <context:component-scan base-package="com.example.ws.soap.service.impl" /> 

    <wss:binding url="/service/desoteServicePort"> 
     <wss:service> 
      <ws:service bean="#desoteService" /> 
     </wss:service> 
    </wss:binding> 

</beans> 

这有什么错我的档案?

命名空间不匹配。你声明的命名空间:

<beans ... 
    xmlns:ws="http://jax-ws.dev.java.net/spring/core" 
    xmlns:wss="http://jax-ws.dev.java.net/spring/servlet" 

,但是当你与该模式的位置做了关联中,你使用了不同的命名空间:

xsi:schemaLocation=" ... 

    http://jax-ws.java.net/spring/core http://.../core.xsd 
    http://jax-ws.java.net/spring/servlet http://.../servlet.xsd"> 

有一个在你宣称的命名空间一个额外的“开发”不存在于与XSD位置关联的名称空间中。

您可能会混淆不同版本的Spring。

+0

问题是,它是从官方网站的纯副本/粘贴,我不能使它的工作。有一个404与http://jax-ws.dev.java。net/* – thibon

+0

作为一个名称空间,该URL不必实际运行。但是如果你将一个实例与一个Schema关联起来(在这里就是这种情况),你需要用'xmlns'声明名称空间(和前缀),然后将该名称空间与一个模式位置相关联。命名空间字符串必须相同(即使是额外的'/'也会导致失败)。尝试从'xmlns'声明中删除'.dev'。 – helderdarocha

+0

将链接发布到您从中获取标题的网站。并检查你的依赖关系。 Spring实际上试图从JAR本地读取模式。命名空间用于检索它。如果你安装了错误的Spring版本,它将无法工作。 – helderdarocha

正如@helderdarocha指出的那样,该示例有效,但文档错误。自从上次更新至JAX-WS Commons以来的一年内,这种惊讶并未得到解决。

这就是说,下面的标题(从here)工作原理:

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
     xmlns:ws="http://jax-ws.dev.java.net/spring/core" 
     xmlns:wss="http://jax-ws.dev.java.net/spring/servlet" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation=" 
     http://www.springframework.org/schema/beans 
     http://www.springframework.org/schema/beans/spring-beans-2.0.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"> 

这是从有许多答案的问题很长一段时间,但这里是从这些收集简短的回答。

有导致此错误的两个问题:在applicationContext.xml中

  1. 错误的XSD定义。它由复制和粘贴从这个doc引起的。它必须是:

    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

注意在URL开发核心和servlet。不要错过

  1. 使用适合JAXWS依赖与Maven的POM春天库。就像这样:

    <dependency> <groupId>org.jvnet.jax-ws-commons.spring</groupId> <artifactId>jaxws-spring</artifactId> <version>1.9</version> <exclusions> <exclusion> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> </exclusion> <exclusion> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> </exclusion> <exclusion> <groupId>org.jvnet.staxex</groupId> <artifactId>stax-ex</artifactId> </exclusion> </exclusions> </dependency>

  2. 然后一切工作正常!

开始=>