我已经参考了这些使用出站网关发送POST参数的示例。
>
https://github.com/spring-projects/spring-integration-samples/tree/master/medirement/multipart-http
Spring集成-如何使用http出站网关发送POST参数
不过我也有例外
网关接口
import org.springframework.http.HttpStatus;
import java.util.Map;
public interface MultipartRequestGateway {
HttpStatus postMultipartRequest(Map<String, Object> multipartRequest);
}
public class TestClient {
public static void main(String[] args) {
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
"/META-INF/spring/integration/http-outbound-config.xml");
Map<String, Object> requestMap = new HashMap<String, Object>();
requestMap.put("cardNo", "4444333322221111");
requestMap.put("currencyCode", "USD");
requestMap.put("amount", "10.00");
MultipartRequestGateway requestGateway = context.getBean("requestGateway", MultipartRequestGateway.class);
HttpStatus httpStatus = requestGateway.postMultipartRequest(requestMap);
}
}
public class HttpClientFactory extends AbstractFactoryBean<HttpClient> {
@Override
public Class<?> getObjectType() {
return HttpClient.class;
}
@Override
protected HttpClient createInstance() throws Exception {
KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
TrustStrategy allTrust = new TrustStrategy() {
public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException {
return true;
}
};
SSLContext sslcontext = SSLContexts.custom().useTLS().loadTrustMaterial(trustStore, allTrust).build();
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslcontext, SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
CloseableHttpClient httpClient = HttpClients.custom().setSSLSocketFactory(sslsf).build();
return httpClient;
}
}
<!--REQUEST CHANNELS-->
<int:channel id="PaymentAuthRequestChannel"/>
<!--ROUTING CHANNELS-->
<int:channel id="PaymentAuthRoutingChannel"/>
<!--ERROR CHANNEL-->
<int:channel id="ErrorChannel"/>
<!--GATEWAY-->
<int:gateway id="requestGateway"
service-interface="org.springframework.integration.samples.http.MultipartRequestGateway"
default-request-channel="PaymentAuthRoutingChannel">
<int:default-header name="Api-Key" value="XYZ" />
<int:default-header name="Accept" value="application/json; v=3"/>
<int:default-header name="Content-Type" value="application/x-www-form-urlencoded"/>
</int:gateway>
<!--ROUTERS-->
<int:recipient-list-router id="paymentAuthRouter" input-channel="PaymentAuthRoutingChannel" default-output-channel="ErrorChannel">
<int:recipient selector-expression="true" channel="PaymentAuthRequestChannel"/>
</int:recipient-list-router>
<!--PAYMENT-->
<int-http:outbound-gateway
id="Auth Outbound Gateway"
request-channel="PaymentAuthRequestChannel"
reply-channel="PaymentAuthReplyChannel"
request-factory="sslFactory"
header-mapper="headerMapper"
url="https://XX.XX.XX.XXX:11210/int-tsys-cc-payment-auth-web/integration/tsys/credit-cards/payments/xyz"
http-method="POST"
expected-response-type="org.springframework.http.HttpStatus"
extract-request-payload="true">
</int-http:outbound-gateway>
<!--TRANSFORMER-->
<int:transformer input-channel="PaymentAuthRequestChannel"
output-channel="PaymentAuthReplyChannel"
expression="payload.statusCode"/>
<!--SSL-->
<bean id="sslFactory" class="org.springframework.http.client.HttpComponentsClientHttpRequestFactory">
<constructor-arg ref="httpClient"/>
</bean>
<bean id="httpClient" class="org.springframework.integration.samples.http.HttpClientFactory" />
<bean id="httpRequestFactory" class="org.springframework.http.client.HttpComponentsClientHttpRequestFactory">
<constructor-arg ref="httpClient"/>
</bean>
<!--HEADER MAPPERS-->
<bean id="headerMapper"
class="org.springframework.integration.http.support.DefaultHttpHeaderMapper">
<property name="inboundHeaderNames" value="*" />
<property name="outboundHeaderNames" value="Api-Key, Accept, Content-Type" />
<property name="userDefinedHeaderPrefix" value="" />
</bean>
StackTrace-1:java.lang.String不能强制转换为java.util.Map
16:36:30.913 INFO [main][org.springframework.integration.endpoint.EventDrivenConsumer] started Post Payments Outbound Gateway
16:36:30.913 INFO [main][org.springframework.integration.endpoint.EventDrivenConsumer] Adding {http:outbound-gateway:Auth Outbound Gateway} as a subscriber to the 'PaymentAuthRequestChannel' channel
16:36:30.914 INFO [main][org.springframework.integration.channel.DirectChannel] Channel 'org.springframework.context.support.ClassPathXmlApplicationContext@7960847b.PaymentAuthRequestChannel' has 1 subscriber(s).
16:36:30.914 INFO [main][org.springframework.integration.endpoint.EventDrivenConsumer] started Auth Outbound Gateway
16:36:30.914 INFO [main][org.springframework.integration.endpoint.EventDrivenConsumer] Adding {logging-channel-adapter:_org.springframework.integration.errorLogger} as a subscriber to the 'errorChannel' channel
16:36:30.914 INFO [main][org.springframework.integration.channel.PublishSubscribeChannel] Channel 'org.springframework.context.support.ClassPathXmlApplicationContext@7960847b.errorChannel' has 1 subscriber(s).
16:36:30.914 INFO [main][org.springframework.integration.endpoint.EventDrivenConsumer] started _org.springframework.integration.errorLogger
Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Map
at org.springframework.integration.http.outbound.HttpRequestExecutingMessageHandler.createHttpEntityFromPayload(HttpRequestExecutingMessageHandler.java:461)
at org.springframework.integration.http.outbound.HttpRequestExecutingMessageHandler.generateHttpRequest(HttpRequestExecutingMessageHandler.java:437)
at org.springframework.integration.http.outbound.HttpRequestExecutingMessageHandler.handleRequestMessage(HttpRequestExecutingMessageHandler.java:370)
at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:99)
更新的Stacktrace
StackTrace-2:415不支持的媒体类型
12:06:19.246 DEBUG [main][org.springframework.beans.factory.support.DefaultListableBeanFactory] Returning cached instance of singleton bean 'integrationEvaluationContext'
12:06:19.248 DEBUG [main][org.springframework.integration.channel.DirectChannel] preSend on channel 'PaymentAuthRequestChannel', message: GenericMessage [payload={currencyCode=USD, paymentAmount=100.00, cardNumber=4791247299592081}, headers={replyChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel@6253c26, errorChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel@6253c26, Accept=application/json; v=3, id=3ddeae24-ae0a-33c0-55b9-7d8039cc8db1, Api-Key=XYZ, Content-Type=application/x-www-form-urlencoded, timestamp=1450026379245}]
12:06:19.248 DEBUG [main][org.springframework.integration.http.outbound.HttpRequestExecutingMessageHandler] org.springframework.integration.http.outbound.HttpRequestExecutingMessageHandler#0 received message: GenericMessage [payload={currencyCode=USD, paymentAmount=100.00, cardNumber=4791247299592081}, headers={replyChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel@6253c26, errorChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel@6253c26, Accept=application/json; v=3, id=3ddeae24-ae0a-33c0-55b9-7d8039cc8db1, Api-Key=XYZ, Content-Type=application/x-www-form-urlencoded, timestamp=1450026379245}]
12:06:19.249 DEBUG [main][org.springframework.integration.http.support.DefaultHttpHeaderMapper] outboundHeaderNames=[Api-Key, Accept, Content-Type]
12:06:19.249 DEBUG [main][org.springframework.integration.http.support.DefaultHttpHeaderMapper] headerName=[replychannel] WILL NOT be mapped
12:06:19.249 DEBUG [main][org.springframework.integration.http.support.DefaultHttpHeaderMapper] headerName=[errorchannel] WILL NOT be mapped
12:06:19.249 DEBUG [main][org.springframework.integration.http.support.DefaultHttpHeaderMapper] headerName=[accept] WILL be mapped, matched pattern=accept
12:06:19.249 DEBUG [main][org.springframework.integration.http.support.DefaultHttpHeaderMapper] setting headerName=[Accept], value=application/json; v=3
12:06:19.250 DEBUG [main][org.springframework.integration.http.support.DefaultHttpHeaderMapper] headerName=[id] WILL NOT be mapped
12:06:19.250 DEBUG [main][org.springframework.integration.http.support.DefaultHttpHeaderMapper] headerName=[api-key] WILL be mapped, matched pattern=api-key
12:06:19.250 DEBUG [main][org.springframework.integration.http.support.DefaultHttpHeaderMapper] setting headerName=[Api-Key], value=XYZ
12:06:19.250 DEBUG [main][org.springframework.integration.http.support.DefaultHttpHeaderMapper] headerName=[content-type] WILL be mapped, matched pattern=content-type
12:06:19.250 DEBUG [main][org.springframework.integration.http.support.DefaultHttpHeaderMapper] setting headerName=[Content-Type], value=application/x-www-form-urlencoded
12:06:19.250 DEBUG [main][org.springframework.integration.http.support.DefaultHttpHeaderMapper] headerName=[timestamp] WILL NOT be mapped
12:06:19.270 DEBUG [main][org.springframework.web.client.RestTemplate] Created POST request for "https://XX.XX.XX.XXX:11210/int-tsys-cc-payment-auth-web/integration/tsys/credit-cards/payments/xyz"
12:06:19.271 DEBUG [main][org.springframework.web.client.RestTemplate] Setting request Accept header to [text/plain, */ *]
12:06:19.272 DEBUG [main][org.springframework.web.client.RestTemplate] Writing [{currencyCode=[USD], paymentAmount=[100.00], cardNumber=[4444333322221111]}] as "application/x-www-form-urlencoded" using [org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter@4145bad8]
12:06:19.692 DEBUG [main][org.springframework.web.client.RestTemplate] POST request for "https://XX.XX.XX.XXX:11210/int-tsys-cc-payment-auth-web/integration/tsys/credit-cards/payments/xyz" resulted in 415 (Unsupported Media Type); invoking error handler
Exception in thread "main" org.springframework.web.client.HttpClientErrorException: 415 Unsupported Media Type
12:06:19.694 DEBUG [main][org.springframework.integration.gateway.GatewayProxyFactoryBean$MethodInvocationGateway] failure occurred in gateway sendAndReceive: HTTP request execution failed for URI [https://XX.XX.XX.XXX:11210/int-tsys-cc-payment-auth-web/integration/tsys/credit-cards/payments/xyz]; nested exception is org.springframework.web.client.HttpClientErrorException: 415 Unsupported Media Type
at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:91)
at org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:636)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:592)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:567)
at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:488)
at org.springframework.integration.http.outbound.HttpRequestExecutingMessageHandler.handleRequestMessage(HttpRequestExecutingMessageHandler.java:382)
at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:99)
at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:127)
at org.springframework.integration.dispatcher.AbstractDispatcher.tryOptimizedDispatch(AbstractDispatcher.java:116)
at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:147)
at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:120)
at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:77)
at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:442)
at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:392)
at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:115)
at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:45)
注意:在spring-integration配置xml中,如果我将内容类型从application/x-www-form-urlencoded更改为application/json,即
<int:default-header name="Content-Type" value="application/json"/>
13:32:29.670 DEBUG [main][org.springframework.integration.http.support.DefaultHttpHeaderMapper] outboundHeaderNames=[Api-Key, Accept, Content-Type]
13:32:29.670 DEBUG [main][org.springframework.integration.http.support.DefaultHttpHeaderMapper] headerName=[replychannel] WILL NOT be mapped
13:32:29.670 DEBUG [main][org.springframework.integration.http.support.DefaultHttpHeaderMapper] headerName=[errorchannel] WILL NOT be mapped
13:32:29.670 DEBUG [main][org.springframework.integration.http.support.DefaultHttpHeaderMapper] headerName=[accept] WILL be mapped, matched pattern=accept
13:32:29.670 DEBUG [main][org.springframework.integration.http.support.DefaultHttpHeaderMapper] setting headerName=[Accept], value=application/json; v=3
13:32:29.671 DEBUG [main][org.springframework.integration.http.support.DefaultHttpHeaderMapper] headerName=[id] WILL NOT be mapped
13:32:29.671 DEBUG [main][org.springframework.integration.http.support.DefaultHttpHeaderMapper] headerName=[api-key] WILL be mapped, matched pattern=api-key
13:32:29.671 DEBUG [main][org.springframework.integration.http.support.DefaultHttpHeaderMapper] setting headerName=[Api-Key], value=XYZ
13:32:29.671 DEBUG [main][org.springframework.integration.http.support.DefaultHttpHeaderMapper] headerName=[content-type] WILL be mapped, matched pattern=content-type
13:32:29.671 DEBUG [main][org.springframework.integration.http.support.DefaultHttpHeaderMapper] setting headerName=[Content-Type], value=application/json
13:32:29.671 DEBUG [main][org.springframework.integration.http.support.DefaultHttpHeaderMapper] headerName=[timestamp] WILL NOT be mapped
Exception in thread "main" org.springframework.web.client.RestClientException: Could not write request: no suitable HttpMessageConverter found for request type [java.util.HashMap] and content type [application/json]
at org.springframework.web.client.RestTemplate$HttpEntityRequestCallback.doWithRequest(RestTemplate.java:806)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:589)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:567)
at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:488)
at org.springframework.integration.http.outbound.HttpRequestExecutingMessageHandler.handleRequestMessage(HttpRequestExecutingMessageHandler.java:382)
at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:99)
at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:127)
at org.springframework.integration.dispatcher.AbstractDispatcher.tryOptimizedDispatch(AbstractDispatcher.java:116)
at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:147)
at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:120)
at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:77)
at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:442)
at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:392)
at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:115)
at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:45)
at org.springframework.messaging.core.AbstractMessageSendingTemplate.send(AbstractMessageSendingTemplate.java:105)
at org.springframework.integration.router.AbstractMessageRouter.handleMessageInternal(AbstractMessageRouter.java:166)
at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:127)13:32:29.686 DEBUG [main][org.springframework.web.client.RestTemplate] Created POST request for "https://XX.XX.XX.XXXX:11210/int-tsys-cc-payment-auth-web/integration/tsys/credit-cards/payments/xyz"
13:32:29.686 DEBUG [main][org.springframework.web.client.RestTemplate] Setting request Accept header to [text/plain, */*]
13:32:29.688 DEBUG [main][org.springframework.integration.gateway.GatewayProxyFactoryBean$MethodInvocationGateway] failure occurred in gateway sendAndReceive: HTTP request execution failed for URI [https://XX.XX.XX.XXXX:11210/int-tsys-cc-payment-auth-web/integration/tsys/credit-cards/payments/xyz]; nested exception is org.springframework.web.client.RestClientException: Could not write request: no suitable HttpMessageConverter found for request type [java.util.HashMap] and content type [application/json]
at org.springframework.integration.dispatcher.AbstractDispatcher.tryOptimizedDispatch(AbstractDispatcher.java:116)
at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:147)
at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:120)
4:49:48.639 DEBUG [main][org.springframework.integration.http.support.DefaultHttpHeaderMapper] headerName=[timestamp] WILL NOT be mapped
14:49:48.663 DEBUG [main][org.springframework.web.client.RestTemplate] Created POST request for "https://XX.XX.XX.XXX:11210/int-tsys-cc-payment-auth-web/integration/tsys/credit-cards/payments/xyz"
14:49:48.666 DEBUG [main][org.springframework.web.client.RestTemplate] Setting request Accept header to [text/plain, application/json, application/*+json, */*]
14:49:48.680 DEBUG [main][org.springframework.web.client.RestTemplate] Writing [{currencyCode=USD, paymentAmount=100.00, cardNumber=4444333322221111}] as "application/json" using [org.springframework.http.converter.json.MappingJackson2HttpMessageConverter@7b7fdc8]
14:49:49.758 DEBUG [main][org.springframework.web.client.RestTemplate] POST request for "https://XX.XX.XX.XXX:11210/int-tsys-cc-payment-auth-web/integration/tsys/credit-cards/payments/xyz" resulted in 201 (Created)
14:49:49.759 DEBUG [main][org.springframework.integration.http.support.DefaultHttpHeaderMapper] inboundHeaderNames=[*]
14:49:49.760 DEBUG [main][org.springframework.integration.http.support.DefaultHttpHeaderMapper] headerName=[set-cookie] WILL be mapped, matched pattern=*
14:49:49.760 DEBUG [main][org.springframework.integration.http.support.DefaultHttpHeaderMapper] setting headerName=[Set-Cookie], value=[JSESSIONID=9F2928189B07D0E3F54D83EA28C36C67; Path=/int-tsys-cc-payment-auth-web/; Secure; HttpOnly]
14:49:49.760 DEBUG [main][org.springframework.integration.http.support.DefaultHttpHeaderMapper] headerName=[x-content-type-options] WILL be mapped, matched pattern=*
14:49:49.760 DEBUG [main][org.springframework.integration.http.support.DefaultHttpHeaderMapper] setting headerName=[X-Content-Type-Options], value=[nosniff]
14:49:49.760 DEBUG [main][org.springframework.integration.http.support.DefaultHttpHeaderMapper] headerName=[x-xss-protection] WILL be mapped, matched pattern=*
14:49:49.760 DEBUG [main][org.springframework.integration.http.support.DefaultHttpHeaderMapper] setting headerName=[X-XSS-Protection], value=[1; mode=block]
14:49:49.760 DEBUG [main][org.springframework.integration.http.support.DefaultHttpHeaderMapper] headerName=[cache-control] WILL be mapped, matched pattern=*
14:49:49.760 DEBUG [main][org.springframework.integration.http.support.DefaultHttpHeaderMapper] setting headerName=[Cache-Control], value=no-cache, no-store, max-age=0, must-revalidate
14:49:49.760 DEBUG [main][org.springframework.integration.http.support.DefaultHttpHeaderMapper] headerName=[pragma] WILL be mapped, matched pattern=*
14:49:49.760 DEBUG [main][org.springframework.integration.http.support.DefaultHttpHeaderMapper] setting headerName=[Pragma], value=no-cache
14:49:49.760 DEBUG [main][org.springframework.integration.http.support.DefaultHttpHeaderMapper] headerName=[expires] WILL be mapped, matched pattern=*
14:49:49.761 DEBUG [main][org.springframework.integration.http.support.DefaultHttpHeaderMapper] headerName=[strict-transport-security] WILL be mapped, matched pattern=*
14:49:49.761 DEBUG [main][org.springframework.integration.http.support.DefaultHttpHeaderMapper] setting headerName=[Strict-Transport-Security], value=[max-age=31536000 ; includeSubDomains]
14:49:49.761 DEBUG [main][org.springframework.integration.http.support.DefaultHttpHeaderMapper] headerName=[x-frame-options] WILL be mapped, matched pattern=*
14:49:49.761 DEBUG [main][org.springframework.integration.http.support.DefaultHttpHeaderMapper] setting headerName=[X-Frame-Options], value=[DENY]
14:49:49.761 DEBUG [main][org.springframework.integration.http.support.DefaultHttpHeaderMapper] headerName=[accept] WILL be mapped, matched pattern=*
14:49:49.761 DEBUG [main][org.springframework.integration.http.support.DefaultHttpHeaderMapper] setting headerName=[Accept], value=[application/json;v=3]
14:49:49.761 DEBUG [main][org.springframework.integration.http.support.DefaultHttpHeaderMapper] headerName=[content-length] WILL be mapped, matched pattern=*
14:49:49.762 DEBUG [main][org.springframework.integration.http.support.DefaultHttpHeaderMapper] setting headerName=[Content-Length], value=0
14:49:49.762 DEBUG [main][org.springframework.integration.http.support.DefaultHttpHeaderMapper] headerName=[date] WILL be mapped, matched pattern=*
14:49:49.763 DEBUG [main][org.springframework.integration.http.support.DefaultHttpHeaderMapper] setting headerName=[Date], value=1,450,036,189,000
14:49:49.763 DEBUG [main][org.springframework.integration.http.support.DefaultHttpHeaderMapper] headerName=[server] WILL be mapped, matched pattern=*
14:49:49.763 DEBUG [main][org.springframework.integration.http.support.DefaultHttpHeaderMapper] setting headerName=[Server], value=[XYZ]
14:49:49.764 DEBUG [main][org.springframework.integration.channel.DirectChannel] postSend (sent=true) on channel 'PaymentAuthRequestChannel', message: GenericMessage [payload={currencyCode=USD, paymentAmount=100.00, cardNumber=4444333322221111}, headers={replyChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel@51bd8b5c, errorChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel@51bd8b5c, Accept=application/json; v=3, id=ca7b5634-3721-6a1b-9f20-439ceab25831, Api-Key=XYZ, Content-Type=application/json, timestamp=1450036188634}]
14:49:49.764 DEBUG [main][org.springframework.integration.channel.DirectChannel] postSend (sent=true) on channel 'PaymentAuthRoutingChannel', message: GenericMessage [payload={currencyCode=USD, paymentAmount=100.00, cardNumber=4444333322221111}, headers={replyChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel@51bd8b5c, errorChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel@51bd8b5c, Accept=application/json; v=3, id=ca7b5634-3721-6a1b-9f20-439ceab25831, Api-Key=XYZ, Content-Type=application/json, timestamp=1450036188634}]
14:49:49.764 DEBUG [main][org.springframework.beans.factory.support.DefaultListableBeanFactory] Returning cached instance of singleton bean 'integrationConversionService'
Exception in thread "main" org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type org.springframework.http.ResponseEntity<?> to type java.lang.String
at org.springframework.core.convert.support.GenericConversionService.handleConverterNotFound(GenericConversionService.java:313)
at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:195)
at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:176)
at org.springframework.integration.gateway.GatewayProxyFactoryBean.convert(GatewayProxyFactoryBean.java:593)
at org.springframework.integration.gateway.GatewayProxyFactoryBean.invokeGatewayMethod(GatewayProxyFactoryBean.java:429)
at org.springframework.integration.gateway.GatewayProxyFactoryBean.doInvoke(GatewayProxyFactoryBean.java:382)
at org.springframework.integration.gateway.GatewayProxyFactoryBean.invoke(GatewayProxyFactoryBean.java:373)
at org.springframework.integration.gateway.GatewayCompletableFutureProxyFactoryBean.invoke(GatewayCompletableFutureProxyFactoryBean.java:64)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at com.sun.proxy.$Proxy6.echo(Unknown Source)
at org.springframework.integration.samples.http.RTFAOrchestrationTest.main(RTFAOrchestrationTest.java:22)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
Process finished with exit code 1
15:42:38.771 DEBUG [main][org.springframework.beans.factory.support.DefaultListableBeanFactory] Returning cached instance of singleton bean 'integrationEvaluationContext'
15:42:38.772 DEBUG [main][org.springframework.beans.factory.support.DefaultListableBeanFactory] Returning cached instance of singleton bean 'integrationConversionService'
15:42:38.775 DEBUG [main][org.springframework.integration.handler.ExpressionEvaluatingMessageProcessor] SpEL Expression evaluation failed with EvaluationException.
org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 8): Property or field 'statusCode' cannot be found on object of type 'java.util.HashMap' - maybe not public?
at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:224)
at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:94)
at org.springframework.expression.spel.ast.PropertyOrFieldReference.access$000(PropertyOrFieldReference.java:46)
验证了用于以下来自SOAP-UI for REST的REST请求的API
POST https://XX.XX.XX.XXXX:11210/int-tsys-cc-payment-auth-web/integration/tsys/credit-cards/payments/fadsfsad HTTP/1.1
Accept-Encoding: gzip,deflate
Api-Key: XYZ
Accept: application/json;v=3
Content-Type: application/json
Content-Length: 84
Host: XX.XX.XX.XXXX:11210
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
{
"cardNumber":"4444333322221111",
"currencyCode":"USD",
"paymentAmount":"12.00"
}
似乎映射
正以某种方式转换为字符串
;不清楚如何在您所显示的配置中发生这种情况。第一步(总是)是打开org.springframework.integration
的调试日志记录。您应该看到消息预置在通道'request channel
上,以及...HttpRequestExecutingMessageHandler#0 received message...
,中间没有任何内容。
我试图理解在Spring集成中应该如何处理错误。我找到了关于的文档,我试图使用它,但没有捕获异常。 下面是我的HTTP出站网关: 我不明白应该在哪里捕捉这个组件引发的异常(比如500 HTTP错误) 路由由启动。我尝试添加属性: 我尝试使用自定义错误通道。我还尝试重写现有的ErrorChannel:
https:// /gateway/services/integration/api/getrecordsfromservice1?transactionid=1111111111&id=100100100100157 integration是为IntegrationService在网关中注册的服务名称。类似地,service1是用于service1的。 我不能理解的是: null 我的入站和出站
我对Spring集成有一个问题。我使用的是Spring Boot 1.4.0.Release,Spring Integration 4.3.1.Release,Spring Integration DSL 1.2.0.M1。 我想做的是: 我尝试过使用SpEl表达式,这可能是正确的方法,但我没有让它起作用。
我试图使用Spring Integration和HTTP出站网关组合一个非常简单的HTTP POST示例。 我需要能够发送带有一些POST参数的HTTP POST消息,就像使用: 如果向接口方法发送一个简单的作为参数,我可以让它工作(没有POST参数),但我需要发送一个pojo,其中pojo的每个属性都成为POST参数。 我有以下SI配置: 我的接口如下所示: 我的类如下所示: 我为此搜索了大量的
我是Spring integration SFTP的新手。现在,我想从多个目录下载文件。那么SFTP出站网关似乎是我的首选,但我只找到了使用XML config的示例。如何使用Java config来实现这一点呢?我的配置类: 但当我启动应用程序时,什么也没发生,哪里出了问题? ---更新---我的测试类
我尝试了出站网关,如: 中所述 https://github.com/spring-projects/spring-integration-samples/blob/master/basic/ftp/src/test/resources/meta-inf/spring/integration/ftpoutboundgatewaysample-context.xml 和 http://forum.s