1
我有以下配置:在Spring集成的出站網關傳遞多個參數
<int-http:outbound-gateway id="opgateway" request-channel="rallyUpdateRequest"
url="https://rally1.rallydev.com/slm/webservice/v2.0/defect/9792864541?key={key}"
http-method="POST" request-factory="rallyHttpRequestFactory"
expected-response-type="java.lang.String"
transfer-cookies="true"
reply-channel="rallyUpdateResponse">
<int-http:uri-variable
name="key"
expression="payload.secondArg" />
</int-http:outbound-gateway>
和網關接口:
//@interface
public interface RallyUpdater {
String updateDefect(@Payload String payload, @Header String key);
}
我主要功能:
public static void main(String... args) throws Exception {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(
"context.xml");
....
RallyUpdater updater = ctx.getBean("rallyUpdateGateway", RallyUpdater.class);
String res=updater.updateDefect(defect,key);
System.out.println("Response ::::::::::"+res);
這給我一個錯誤:
*
Exception in thread "main" java.lang.IllegalArgumentException: Cannot determine header name. Possible reasons: -debug is disabled or header name is not explicitly provided via @Header annotation.
at org.springframework.util.Assert.notNull(Assert.java:112)
at org.springframework.integration.gateway.GatewayMethodInboundMessageMapper.determineHeaderName(GatewayMethodInboundMessageMapper.java:229)
at org.springframework.integration.gateway.GatewayMethodInboundMessageMapper.access$500(GatewayMethodInboundMessageMapper.java:80)
at org.springframework.integration.gateway.GatewayMethodInboundMessageMapper$DefaultMethodArgsMessageMapper.toMessage(GatewayMethodInboundMessageMapper.java:300)
at org.springframework.integration.gateway.GatewayMethodInboundMessageMapper$DefaultMethodArgsMessageMapper.toMessage(GatewayMethodInboundMessageMapper.java:262)
at org.springframework.integration.gateway.GatewayMethodInboundMessageMapper.mapArgumentsToMessage(GatewayMethodInboundMessageMapper.java:163)
at org.springframework.integration.gateway.GatewayMethodInboundMessageMapper.toMessage(GatewayMethodInboundMessageMapper.java:158)
at org.springframework.integration.gateway.GatewayMethodInboundMessageMapper.toMessage(GatewayMethodInboundMessageMapper.java:80)
at org.springframework.integration.support.converter.SimpleMessageConverter.toMessage(SimpleMessageConverter.java:82)
at org.springframework.messaging.core.AbstractMessageSendingTemplate.doConvert(AbstractMessageSendingTemplate.java:157)
at org.springframework.messaging.core.AbstractMessagingTemplate.convertSendAndReceive(AbstractMessagingTemplate.java:78)
at org.springframework.messaging.core.AbstractMessagingTemplate.convertSendAndReceive(AbstractMessagingTemplate.java:70)
at org.springframework.integration.gateway.MessagingGatewaySupport.doSendAndReceive(MessagingGatewaySupport.java:347)
at org.springframework.integration.gateway.MessagingGatewaySupport.sendAndReceive(MessagingGatewaySupport.java:324)
at org.springframework.integration.gateway.GatewayProxyFactoryBean.invokeGatewayMethod(GatewayProxyFactoryBean.java:414)
at org.springframework.integration.gateway.GatewayProxyFactoryBean.doInvoke(GatewayProxyFactoryBean.java:374)
at org.springframework.integration.gateway.GatewayProxyFactoryBean.invoke(GatewayProxyFactoryBean.java:365)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
at com.sun.proxy.$Proxy9.updateDefect(Unknown Source)
at com.aa.qcrallysyncmgmt.base.Main.main(Main.java:49)
* **我需要通過有效載荷數據後,並在網址的關鍵。
爲什麼這會拋出錯誤,我們可以給payload.secondArg? 任何其他配置?
感謝Artem的快速反應。 當我把 時,它會拋出相同的錯誤。 這裏是網關: –
2015-02-05 13:29:10
謝謝Artem,我沒有注意到註釋中參數的名稱,它在addig後運行 – 2015-02-05 13:36:21
Artem,我們能否動態修改URL?我也想動態地傳遞9234264541。 當我通過以下方式傳遞鍵時,並將{key}的值傳遞給{key} **「9234264541?key = kj2hkj3h2k43 ..」** 它拋出錯誤: 線程「主」異常org.springframework.web.client.HttpClientErrorException:405方法不允許 – 2015-02-06 09:27:33