Spring Integration - Spring示例配置命名空间问题

时间:2015-08-24 18:44:06

标签: spring spring-integration

问题:在我的spring配置文件中获取元素的命名空间错误。

"无法找到Spring NamespaceHandler for element" int-ws:hyeader-enricher'架构namcespace' http://www.springframework.org/schema/integration/ws'

描述:尝试使用maven在Spring网站上的Spring Integration示例项目中创建一个简单的spring sts spring项目。

我没有在示例目录中找到这个项目供我比较我的。

http://projects.spring.io/spring-integration/

Spring Bean配置文件

<?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:context="http://www.springframework.org/schema/context"
    xmlns:int="http://www.springframework.org/schema/integration"
    xmlns:int-http="http://www.springframework.org/schema/integration/http"
    xmlns:int-ws="http://www.springframework.org/schema/integration/ws"
    xmlns:int-xml="http://www.springframework.org/schema/integration/xml"
    xsi:schemaLocation="http://www.springframework.org/schema/integration/http http://www.springframework.org/schema/integration/http/spring-integration-http.xsd
        http://www.springframework.org/schema/integration/ws http://www.springframework.org/schema/integration/ws/spring-integration-ws.xsd
        http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/integration/xml http://www.springframework.org/schema/integration/xml/spring-integration-xml.xsd">


<!-- Simple Service -->

<int:gateway id="simpleGateway"
    service-interface="foo.TempConverter"
    default-request-channel="simpleExpression" />

<int:service-activator id="expressionConverter"
    input-channel="simpleExpression"
    expression="(payload - 32) / 9 * 5"/>

<!-- Web Service -->

<int:gateway id="wsGateway" service-interface="foo.TempConverter"
    default-request-channel="viaWebService" />

<int:chain id="wsChain" input-channel="viaWebService">
    <int:transformer
       expression="'&lt;FahrenheitToCelsius xmlns=''http://www.w3schools.com/webservices/''&gt;&lt;Fahrenheit&gt;XXX&lt;/Fahrenheit&gt;&lt;/FahrenheitToCelsius&gt;'.replace('XXX', payload.toString())" />
    <int-ws:header-enricher>
        <int-ws:soap-action value="http://www.w3schools.com/webservices/FahrenheitToCelsius"/>
    </int-ws:header-enricher>
    <int-ws:outbound-gateway
        uri="http://www.w3schools.com/webservices/tempconvert.asmx"/>
    <int-xml:xpath-transformer
        xpath-expression="/*[local-name()='FahrenheitToCelsiusResponse']/*[local-name()='FahrenheitToCelsiusResult']"/>
</int:chain>

</beans>

更新 - 解决方案 我不得不添加以下网站上未列出的依赖项。我将其添加到POM文件中。

<dependency>
    <groupId>org.springframework.integration</groupId>
    <artifactId>spring-integration-ws</artifactId>
    <version>4.1.6.RELEASE</version>

</dependency>
<dependency>
    <groupId>org.springframework.integration</groupId>
    <artifactId>spring-integration-xml</artifactId>
    <version>4.1.6.RELEASE</version>
</dependency>

1 个答案:

答案 0 :(得分:1)

Spring XML配置命名空间在运行时需要一个命名空间处理程序(META-INF/spring.handlers类路径资源,通常在类路径上的JAR中,指定处理程序类)。

Spring在运行时发出此消息的原因是因为尚未为该XML元素注册名称空间处理程序。最可能的原因是spring-integration-ws.jar(或者可能是必需的依赖项)在运行时不在类路径上。