- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想将序列化为 byte[]
的对象实例作为 HTTP POST 参数发送到 int-http:outbound-gateway
。
这是我的 Spring 集成配置:
<int:chain input-channel="requestChannel" output-channel="replyChannel">
<int:header-enricher>
<int:header name="contentType" value="application/octet-stream" overwrite="true"/>
</int:header-enricher>
<int-http:outbound-gateway id="gateway"
encode-uri="true" url="http://localhost:8080/myApp?payload={myObject}"
http-method="POST" header-mapper="headerMapper" extract-request-payload="true">
<int-http:uri-variable name="myObject" expression="payload.getSerializedObject()"/>
</int-http:outbound-gateway>
</int:chain>
我已将 contentType
设置为 “application/octet-stream”
,因为我注意到这是 ByteArrayHttpMessageConverter
的 API 文档中指示的 contentType >:
POST 请求已正确生成,但失败并出现错误:
org.springframework.web.client.RestClientException: Could not write request: no suitable HttpMessageConverter found for request type [test.app.RequestPayload] and content type [application/octet-stream]
这是Spring的完整日志,其中有完整的错误消息:
2016-07-21 10:30:37 DEBUG org.springframework.http.client.support.HttpAccessor.createRequest:79 (executor-3) -
Created POST request for "http://localhost:8080/myApp?payload=-84,-19,0,5,115,114,0,16,116,101,115,116,46,67,111,110,116,101,110,105,116,111,114,101,-80,-61,4,81,-17,-9,122,-124,2,0,2,76,0,4,110,111,109,101,116,0,18,76,106,97,118,97,47,108,97,110,103,47,83,116,114,105,110,103,59,76,0,4,116,105,112,111,116,0,11,76,116,101,115,116,47,84,105,112,111,59,120,112,116,0,11,99,111,110,116,101,110,105,116,111,114,101,115,114,0,9,116,101,115,116,46,84,105,112,111,-85,110,71,71,--84,-19,0,5,115,114,0,16,116,101,115,116,46,67,111,110,116,101,110,105,116,111,114,101,-80,-61,4,81,-17,-9,122,-124,2,0,2,76,0,4,110,111,109,101,116,0,18,76,106,97,118,97,47,108,97,110,103,47,83,116,114,105,110,103,59,76,0,4,116,105,112,111,116,0,11,76,116,101,115,116,47,84,105,112,111,59,120,112,116,0,11,99,111,110,116,101,110,105,116,111,114,101,115,114,0,9,116,101,115,116,46,84,105,112,111,-85,110,71,71,-3,12,58,41,2,0,2,76,0,9,109,97,116,101,114,105,97,108,101,113,0,126,0,1,76,0,4,110,111,109,101,113,0,126,0,1,120,112,116,0,9,109,97,116,101,114,105,97,108,101,116,0,4,116,105,112,1118,76,106,97,118,97,47,108,97,110,103,47,83,116,114,105,110,103,59,120,112,116,0,14,82,79,76,69,95,65,78,79,78,89,77,79,85,83,120,113,0,126,0,10,115,114,0,72,111,114,103,46,115,112,114,105,110,103,102,114,97,109,101,119,111,114,107,46,115,101,99,117,114,105,116,121,46,119,101,98,46,97,117,116,104,101,110,116,105,99,97,116,105,111,110,46,87,101,98,65,117,116,104,101,110,116,105,99,97,116,105,111,110,68,101,116,97,105,108,115,0,0,0,0,0,0,1,-102,2,0,2,76,0,13,114,101,109,111,116,101,65,100,100,114,101,115,115,113,0,126,0,12,76,0,9,115,101,115,115,105,111,110,73,100,113,0,126,0,12,120,112,116,0,15,48,58,48,58,48,58,48,58,48,58,48,58,48,58,49,112,118,91,63,-111,116,0,13,97,110,111,110,121,109,111,117,115,85,115,101,114"
2016-07-21 10:30:37 DEBUG org.springframework.integration.channel.AbstractMessageChannel.send:411 (executor-3) -
preSend on channel 'errorChannel', message: ErrorMessage [payload=org.springframework.messaging.MessageHandlingException: HTTP request execution failed for URI [http://localhost:8080/myApp?payload=-84,-19,0,5,115,114,0,16,116,101,115,116,46,67,111,110,116,101,110,105,116,111,114,101,-80,-61,4,81,-17,-9,122,-124,2,0,2,76,0,4,110,111,109,101,116,0,18,76,106,97,118,97,47,108,97,110,103,47,83,116,114,105,110,103,59,76,0,4,116,105,112,111,116,0,11,76,116,101,115,116,47,84,105,112,111,59,120,112,116,0,11,99,111,110,116,101,110,105,116,111,114,101,115,114,0,9,116,101,115,116,46,84,105,112,111,-85,110,71,71,--84,-19,0,5,115,114,0,16,116,101,115,116,46,67,111,110,116,101,110,105,116,111,114,101,-80,-61,4,81,-17,-9,122,-124,2,0,2,76,0,4,110,111,109,101,116,0,18,76,106,97,118,97,47,108,97,110,103,47,83,116,114,105,110,103,59,76,0,4,116,105,112,111,116,0,11,76,116,101,115,116,47,84,105,112,111,59,120,112,116,0,11,99,111,110,116,101,110,105,116,111,114,101,115,114,0,9,116,101,115,116,46,84,105,112,111,-85,110,71,71,-3,12,58,41,2,0,2,76,0,9,109,97,116,101,114,105,97,108,101,113,0,126,0,1,76,0,4,110,111,109,101,113,0,126,0,1,120,112,116,0,9,109,97,116,101,114,105,97,108,101,116,0,4,116,105,112,1118,76,106,97,118,97,47,108,97,110,103,47,83,116,114,105,110,103,59,120,112,116,0,14,82,79,76,69,95,65,78,79,78,89,77,79,85,83,120,113,0,126,0,10,115,114,0,72,111,114,103,46,115,112,114,105,110,103,102,114,97,109,101,119,111,114,107,46,115,101,99,117,114,105,116,121,46,119,101,98,46,97,117,116,104,101,110,116,105,99,97,116,105,111,110,46,87,101,98,65,117,116,104,101,110,116,105,99,97,116,105,111,110,68,101,116,97,105,108,115,0,0,0,0,0,0,1,-102,2,0,2,76,0,13,114,101,109,111,116,101,65,100,100,114,101,115,115,113,0,126,0,12,76,0,9,115,101,115,115,105,111,110,73,100,113,0,126,0,12,120,112,116,0,15,48,58,48,58,48,58,48,58,48,58,48,58,48,58,49,112,118,91,63,-111,116,0,13,97,110,111,110,121,109,111,117,115,85,115,101,114]; nested exception is org.springframework.web.client.RestClientException: Could not write request: no suitable HttpMessageConverter found for request type [test.app.RequestPayload] and content type [application/octet-stream], headers={id=0b397968-8a99-2d59-8f9e-636bd172c3d1, timestamp=1469089837071}]
2016-07-21 10:30:37 DEBUG org.springframework.integration.handler.AbstractMessageHandler.handleMessage:115 (executor-3) -
_org.springframework.integration.errorLogger.handler received message: ErrorMessage [payload=org.springframework.messaging.MessageHandlingException: HTTP request execution failed for URI [http://localhost:8080/myApp?payload=-84,-19,0,5,115,114,0,16,116,101,115,116,46,67,111,110,116,101,110,105,116,111,114,101,-80,-61,4,81,-17,-9,122,-124,2,0,2,76,0,4,110,111,109,101,116,0,18,76,106,97,118,97,47,108,97,110,103,47,83,116,114,105,110,103,59,76,0,4,116,105,112,111,116,0,11,76,116,101,115,116,47,84,105,112,111,59,120,112,116,0,11,99,111,110,116,101,110,105,116,111,114,101,115,114,0,9,116,101,115,116,46,84,105,112,111,-85,110,71,71,--84,-19,0,5,115,114,0,16,116,101,115,116,46,67,111,110,116,101,110,105,116,111,114,101,-80,-61,4,81,-17,-9,122,-124,2,0,2,76,0,4,110,111,109,101,116,0,18,76,106,97,118,97,47,108,97,110,103,47,83,116,114,105,110,103,59,76,0,4,116,105,112,111,116,0,11,76,116,101,115,116,47,84,105,112,111,59,120,112,116,0,11,99,111,110,116,101,110,105,116,111,114,101,115,114,0,9,116,101,115,116,46,84,105,112,111,-85,110,71,71,-3,12,58,41,2,0,2,76,0,9,109,97,116,101,114,105,97,108,101,113,0,126,0,1,76,0,4,110,111,109,101,113,0,126,0,1,120,112,116,0,9,109,97,116,101,114,105,97,108,101,116,0,4,116,105,112,1118,76,106,97,118,97,47,108,97,110,103,47,83,116,114,105,110,103,59,120,112,116,0,14,82,79,76,69,95,65,78,79,78,89,77,79,85,83,120,113,0,126,0,10,115,114,0,72,111,114,103,46,115,112,114,105,110,103,102,114,97,109,101,119,111,114,107,46,115,101,99,117,114,105,116,121,46,119,101,98,46,97,117,116,104,101,110,116,105,99,97,116,105,111,110,46,87,101,98,65,117,116,104,101,110,116,105,99,97,116,105,111,110,68,101,116,97,105,108,115,0,0,0,0,0,0,1,-102,2,0,2,76,0,13,114,101,109,111,116,101,65,100,100,114,101,115,115,113,0,126,0,12,76,0,9,115,101,115,115,105,111,110,73,100,113,0,126,0,12,120,112,116,0,15,48,58,48,58,48,58,48,58,48,58,48,58,48,58,49,112,118,91,63,-111,116,0,13,97,110,111,110,121,109,111,117,115,85,115,101,114]; nested exception is org.springframework.web.client.RestClientException: Could not write request: no suitable HttpMessageConverter found for request type [test.app.RequestPayload] and content type [application/octet-stream], headers={id=0b397968-8a99-2d59-8f9e-636bd172c3d1, timestamp=1469089837071}]
2016-07-21 10:30:37 ERROR org.springframework.integration.handler.LoggingHandler.handleMessageInternal:184 (executor-3) -
org.springframework.messaging.MessageHandlingException: HTTP request execution failed for URI [http://localhost:8080/myApp?payload=-84,-19,0,5,115,114,0,16,116,101,115,116,46,67,111,110,116,101,110,105,116,111,114,101,-80,-61,4,81,-17,-9,122,-124,2,0,2,76,0,4,110,111,109,101,116,0,18,76,106,97,118,97,47,108,97,110,103,47,83,116,114,105,110,103,59,76,0,4,116,105,112,111,116,0,11,76,116,101,115,116,47,84,105,112,111,59,120,112,116,0,11,99,111,110,116,101,110,105,116,111,114,101,115,114,0,9,116,101,115,116,46,84,105,112,111,-85,110,71,71,--84,-19,0,5,115,114,0,16,116,101,115,116,46,67,111,110,116,101,110,105,116,111,114,101,-80,-61,4,81,-17,-9,122,-124,2,0,2,76,0,4,110,111,109,101,116,0,18,76,106,97,118,97,47,108,97,110,103,47,83,116,114,105,110,103,59,76,0,4,116,105,112,111,116,0,11,76,116,101,115,116,47,84,105,112,111,59,120,112,116,0,11,99,111,110,116,101,110,105,116,111,114,101,115,114,0,9,116,101,115,116,46,84,105,112,111,-85,110,71,71,-3,12,58,41,2,0,2,76,0,9,109,97,116,101,114,105,97,108,101,113,0,126,0,1,76,0,4,110,111,109,101,113,0,126,0,1,120,112,116,0,9,109,97,116,101,114,105,97,108,101,116,0,4,116,105,112,1118,76,106,97,118,97,47,108,97,110,103,47,83,116,114,105,110,103,59,120,112,116,0,14,82,79,76,69,95,65,78,79,78,89,77,79,85,83,120,113,0,126,0,10,115,114,0,72,111,114,103,46,115,112,114,105,110,103,102,114,97,109,101,119,111,114,107,46,115,101,99,117,114,105,116,121,46,119,101,98,46,97,117,116,104,101,110,116,105,99,97,116,105,111,110,46,87,101,98,65,117,116,104,101,110,116,105,99,97,116,105,111,110,68,101,116,97,105,108,115,0,0,0,0,0,0,1,-102,2,0,2,76,0,13,114,101,109,111,116,101,65,100,100,114,101,115,115,113,0,126,0,12,76,0,9,115,101,115,115,105,111,110,73,100,113,0,126,0,12,120,112,116,0,15,48,58,48,58,48,58,48,58,48,58,48,58,48,58,49,112,118,91,63,-111,116,0,13,97,110,111,110,121,109,111,117,115,85,115,101,114]; nested exception is org.springframework.web.client.RestClientException: Could not write request: no suitable HttpMessageConverter found for request type [test.app.RequestPayload] and content type [application/octet-stream]
请求负载的构建如下:
public void sendMessage(Object myObject) throws Exception {
MessagingChannel messagingChannel = (MessagingChannel)appContext.getBean("requestChannelBean");
RequestPayload payload = new RequestPayload(serialize(myObject));
Message<RequestPayload> message = MessageBuilder.withPayload(payload).build();
MessageChannel requestChannel = messagingChannel.getRequestChannel();
requestChannel.send(message);
}
public byte[] serialize(Object obj) throws IOException {
try(ByteArrayOutputStream b = new ByteArrayOutputStream()){
try(ObjectOutputStream o = new ObjectOutputStream(b)){
o.writeObject(obj);
}
return b.toByteArray();
}
}
知道如何解决这个问题吗?
最佳答案
您不能通过将 ?payload={myObject}
添加到查询字符串来进行 POST - 消息负载是 POST 正文。
在网关之前向链中添加一个转换器,将主体转换为 byte[]
,它将按需要工作;删除 uri 变量。
关于java - Spring 集成: how to send a Byte Array as POST parameter with an http:outbound-gateway?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38499618/
我正在使用 s.i. 提供的两个组件。拥有一个有效的分配系统 消息(任务)被发送到这个名为 distribution 的 channel ;分发有一个与通知系统关联的窃听器,因此当消息通过分发时我可以
您如何跟踪您网站的出站链接,因为请求记录在目标服务器上,而不是您的? 最佳答案 您可以向将跟踪外部链接的页面添加一个快速 JQuery 脚本,并且可以将它们重定向到您服务器上的一个文件,该文件将跟踪链
我一直在做spring集成 ,我可以使用 ftp-outbound-gateway 从远程服务器下载文件, 但是有一个我还没有解决的问题,如果远程目录包含文件,系统可以正常工作并且将完成而没有任何问题
在我的 Mule-config.xml 中,我使用 2 个查询参数向服务发送 http post...我尝试添加 2 个查询参数,如下所示:
Twilio 标记语言清楚地定义了如何将 INCOMING 调用加入公共(public) session 室。 但我想同时调用几个电话并加入这些电话。如果我在标记语言中使用“拨号”动词,我会接到几个连
跟踪出站链接和表单可能很棘手,因为一旦新页面开始加载,大多数浏览器将停止在当前页面上执行 JavaScript。 这可以通过设置 'transport': 'beacon' 来缓解。 据此suppor
在类似下面的流程中: 我从 file:inbound-endpoint 获取 InputStream 并
当我尝试使用 haraka 和 swaks 发送电子邮件时,出现以下错误: 521 Too many bad commands 我使用以下参数执行swaks: swaks -f from@domain
我们从 SIv3.x 迁移到 SIv4.0.4,发现现在 http-outbound-gateway 设置了错误的内容类型 header 。它不是像这种内容类型那样设置它,而是像 contentTyp
您好,我正在将 spring-integration web 应用程序部署到 apache-tomcat-8.0.36:maven 依赖项是: org.springframew
试图弄清楚如何在 Spring Integration 工作流中最好地对 http:outbound-gateway 进行单元测试。 这是我们的网关的样子: 具体来说,我们想要.. 断言正在发送的对
我正在使用 spring 集成将数据存储在 mongo 数据库中。我使用的是java类(MongoDbStoringMessageHandler),而不是xml配置,并且在数据库中添加一些数据时我找不
尝试使用 Amazon FWS 出站 api 时,无法从中创建订单。出现未知异常。我发现 fws 端点主机不工作。有人可以帮助我使用 fws api 创建订单吗? com.amazonaws.
有章节31.10.2在 SSL 支持的 spring 集成引用中,但是我不能让它与 http:outbound-gateway 一起工作,我可以知道是否有任何带有 http:outbound-gate
面对 spring integration java-dsl 问题,我被卡住了。这是我的流声明代码: @Bean public IntegrationFlow orchestratio
我正在尝试使用 Spring Integration sftp 出站 channel 适配器将文件发送到 sftp。 我收到以下错误.. Caused by: java.lang.IllegalSt
我试图了解 Spring Integration 中应如何处理错误。我发现documentation关于errorChannel,我尝试使用它但没有捕获异常。 这是我的 HTTP 出站网关: 我不
我正在使用 Google 容器引擎启动一个连接到远程服务(在不同的数据中心/提供商中)的集群。正在连接的容器可能没有与之关联的 kubernetes service,并且不需要外部绑定(bind) I
我需要处理 FIX 实现的客户端。从基本设置中我注意到:一旦消息发送,发起者/客户端就会在 Eclipse 中终止,而接受者则继续监听端口。启动器是否也必须无限期运行?我们尝试构建的应用程序必须发送消
我在为无效网关消息设置 channel 时遇到问题: 目前,我遇到了异常 线程“main”中的异常org.springframework.integration.support.channel.Cha
我是一名优秀的程序员,十分优秀!