Java Spring集成:int-http:带有url路径变量的入站网关
我正在尝试使用Spring Integration int http:Inbound gateway测试入站http网关:Java Spring集成:int-http:带有url路径变量的入站网关,java,spring-mvc,spring-integration,Java,Spring Mvc,Spring Integration,我正在尝试使用Spring Integration int http:Inbound gateway测试入站http网关: <int-http:inbound-gateway id="correlateOutgoingMessage" supported-methods="POST" request-channel="toOutCorrelator" reply-channel="fromOutCorrelator" view-name="/correlateOutgoin
<int-http:inbound-gateway id="correlateOutgoingMessage"
supported-methods="POST" request-channel="toOutCorrelator"
reply-channel="fromOutCorrelator" view-name="/correlateOutgoingMessage"
path="/correlateOut/{origin}/{msgtype}/{priority}"
reply-timeout="50000">
<int-http:header name="origin" expression="#pathVariables.origin" />
<int-http:header name="msgtype" expression="#pathVariables.msgtype" />
<int-http:header name="priority" expression="#pathVariables.priority" />
</int-http:inbound-gateway>
My Web.xml:
<servlet>
<servlet-name>correlateOut</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>WEB-INF/intg-schema.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>correlateOut</servlet-name>
<!-- controler/* -->
<url-pattern>/correlateOut/*</url-pattern>
</servlet-mapping>
相关输出
org.springframework.web.servlet.DispatcherServlet
上下文配置位置
WEB-INF/intg-schema.xml
1.
相关输出
/相关输出/*
使用RestTemplate,我试图向网关发出POST请求:
uri=”http://localhost:8080/test/correlateOutgoingMessage/{origin}/{msgtype}/{priority}”
字符串origin=“xxxx”;
整数msgtype=2333;
整数优先级=2;
HttpHeaders=新的HttpHeaders();
headers.setContentType(MediaType.TEXT\u PLAIN);
HttpEntity请求=null;
ResponseEntity httpResponse=null;
请求=新的HttpEntity(messageContent);
httpResponse=template.exchange(uri、HttpMethod.POST、request、,
String.class,geturlparms(origin,msgtype,priority));
我总是找不到404,你能给我一些提示吗
多谢各位 首先,您应该显示用于发送HTTP请求的
uri
从另一端,如果将servlet映射到/correlateOut/*
,则不能在目标映射中使用它,因为所有其他端点都在该上下文下
因此,你的路径应该是路径=“{origin}/{msgtype}/{priority}”
你能在帖子中包含你正在使用的uri吗?
uri = "http://localhost:8080/test/correlateOutgoingMessage/{origin}/{msgtype}/{priority}"
String origin = "xxxx";
Integer msgtype = 2333;
Integer priority = 2;
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.TEXT_PLAIN);
HttpEntity<?> request = null;
ResponseEntity<String> httpResponse = null;
request = new HttpEntity<Object>(messageContent);
httpResponse = template.exchange(uri, HttpMethod.POST, request,
String.class, getUrlParams(origin, msgtype, priority));