3
votes

Issue: Getting namespace errors for elements in my spring config file.

"Unable to locate Spring NamespaceHandler for element "int-ws:hyeader-enricher' of schema namcespace 'http://www.springframework.org/schema/integration/ws '

Description: Trying to create at the Spring Integration sample project from the spring website in a simple spring sts spring project using maven.

I didnt find this project in the sample directory for me to compare mine to.

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

Spring Bean Config File

<?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>

UPDATE - SOLUTION I had to add the following dependencies not listed on there website. I added this to the POM file.

<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

1 Answers

1
votes

Spring XML configuration namespaces need a namespace handler at runtime (the META-INF/spring.handlers class path resources, usually in JARs on the class path, nominate handler classes).

The reason that Spring is giving this message at runtime is because a namespace handler has not been registered for that XML element. The most likely reason is that the spring-integration-ws.jar (or perhaps a required dependency) is not on the class path at runtime.