Peter Smith
Peter Smith

Reputation: 889

spring integration rest service throws 404 error

I am attempting to create a spring integration web application that forwards any payload received via a REST service call to standard out (to be replaced by another backing endpoint later).

When I attempt to visit the web server's url after publishing to weblogic

http://localhost:7001/ws_inboundBlobDispatcher/rest/services/inboundBlobDispatch/110/publish

I receive a 404 error. I don't know why this is or if the rest endpoint is being created.

My entire spring configuration is below:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    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.xsd
        http://www.springframework.org/schema/integration
        http://www.springframework.org/schema/integration/spring-integration.xsd
        http://www.springframework.org/schema/integration/http
        http://www.springframework.org/schema/integration/http/spring-integration-http.xsd
        http://www.springframework.org/schema/integration/stream
        http://www.springframework.org/schema/integration/stream/spring-integration-stream.xsd"
    xmlns:int="http://www.springframework.org/schema/integration"
    xmlns:int-http="http://www.springframework.org/schema/integration/http"
    xmlns:stream="http://www.springframework.org/schema/integration/stream">

    <int:annotation-config/>

    <!-- Inbound/Outbound Channels -->
    <int:channel id="inboundBlobMessages" />
    <int:channel id="inboundBlobResponse" />

    <int-http:inbound-gateway id="inboundEmployeeSearchRequestGateway"
        supported-methods="GET, POST"
        request-channel="inboundBlobMessages"
        reply-channel="inboundBlobResponse"
        mapped-response-headers="Return-Status, Return-Status-Msg, HTTP_RESPONSE_HEADERS"
        path="/rest/services/inboundBlobDispatch/{uniqueKey}/publish"
        reply-timeout="50000"
         />

    <stream:stdout-channel-adapter channel="inboundBlobMessages" append-newline="true"/>

</beans>

Below is my web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4"
    xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <display-name>YourSimpleWebAppNameHere</display-name>

    <servlet>
        <servlet-name>rest</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>rest</servlet-name>
        <url-pattern>/rest/*</url-pattern>
    </servlet-mapping>

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <session-config>
        <session-timeout>60</session-timeout>
    </session-config>

</web-app>

rest-servlet.xml looks like this:

<?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" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
            http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">


</beans>

Upvotes: 0

Views: 720

Answers (1)

Dave Syer
Dave Syer

Reputation: 58114

I believe your <int-http:inbound-gateway/> has to be in the servlet context (and yours is empty, right?). Also you have a duplicated /rest path prefix (if you define it for the servlet you don't need it in the request mapping in the endpoint).

Upvotes: 2

Related Questions