Spring integration 执行接受多部分参数的rest服务时,未找到合适的HttpMessageConverter错误

Spring integration 执行接受多部分参数的rest服务时,未找到合适的HttpMessageConverter错误,spring-integration,Spring Integration,我在我的项目中使用Spring集成。我正在尝试执行一个rest服务,该服务使用multipart/formdata输入参数。我使用inthttp:outboundgateway来执行rest服务。代码如下: 但是当我执行上面的代码时,我得到了以下错误 Caused by: org.springframework.web.client.RestClientException: Could not write request: no suitable HttpMessageConverter f

我在我的项目中使用Spring集成。我正在尝试执行一个rest服务,该服务使用multipart/formdata输入参数。我使用inthttp:outboundgateway来执行rest服务。代码如下:


但是当我执行上面的代码时,我得到了以下错误

Caused by: org.springframework.web.client.RestClientException: Could not write request: no suitable HttpMessageConverter found for request type [org.springframework.integration.message.GenericMessage] and content type [application/x-java-serialized-object]
    at org.springframework.web.client.RestTemplate$HttpEntityRequestCallback.doWithRequest(RestTemplate.java:665)
    at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:481)
    at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:460)
    at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:409)
    at org.springframework.integration.http.outbound.HttpRequestExecutingMessageHandler.handleRequestMessage(HttpRequestExecutingMessageHandler.java:372)
    ... 121 more
以下是准备我的多部分请求的java代码:

公共消息BuildMultipartTTPoutBoundGatewayRequest(消息中的消息)引发异常{
logger.debug(“*************构建多端口PoutBoundGateway请求启动*************************”);
字符串inMsgPayload=(字符串)inMessage.getPayload();
SOAXml-SOAXml=parseSOAXml(inMsgPayload);
字符串restURL=null;
字符串contentType=null;
字符串acceptHdr=null;
字符串userId=null;
字符串密码=null;
字符串businessAreaName=null;
字符串typeName=null;
字符串attachmentLocation=null;
字符串httpMethod=null;
Message outMessage=null;
MessageHeaders inMsgHdrs=null;
MessageBuilder msgBuild=null;
字符串授权=null;
//TODO:文件位置需要更改为标准位置
String fileLocation=“C:\\source.xml”;
//如果我们到达这里意味着,这是AWD系统
restURL=getAwdSOAService(soaXml);
Document Document=XmlParserUtil.convertString2Document(inMsgPayload);
userId=XmlParserUtil.getNodeValue(文档,//userId);
password=XmlParserUtil.getNodeValue(文档“//PQcreateAttachment/password”);
businessAreaName=XmlParserUtil.getNodeValue(文档“//businessAreaName”);
typeName=XmlParserUtil.getNodeValue(文档,//typeName);
httpMethod=XmlParserUtil.getNodeValue(文档,//METHOD);
attachmentLocation=XmlParserUtil.getNodeValue(文档,//attachmentLocation”);
//构造源xml
//创建文档
Document sourceDocument=DocumentHelper.createDocument();
元素sourceInstance=sourceDocument.addElement(“createSourceInstance”);
addAttribute(“xmlns”http://www.dsttechnologies.com/awd/rest/v1");
元素orderItem=sourceInstance.addElement(“businessAreaName”);
orderItem.setText(“SAMPLEBA”);
元素orderItemDesc=sourceInstance.addElement(“typeName”);
orderItemDesc.setText(“样本”);
//创建源xml文件
创建xmlfileusingdom4j(sourceDocument,fileLocation);
授权=getBasicAuthorization(用户ID、密码);
资源源=新类路径资源(文件位置);
资源附件=新类路径资源(attachmentLocation);
Map multipartMap=newhashmap();
multipartMap.put(“源”,source);
multipartMap.put(“附件”,attachment);
info(“创建的多部分请求:“+multipartMap”);
inMessage=buildMessageForMultipart(multipartMap);
//contentType=csProps.getHttpPawdContentTypeValue();
acceptHdr=csProps.getHttpPawdAcceptTypeValue();
//authorization=getBasicAuthorization(soaXml.getUserid(),decriptPassword(soaXml.getPassword());
inMsgHdrs=inMessage.getHeaders();
msgBuild=MessageBuilder.withPayload(inMessage).copyHeaders(inMsgHdrs);
removeHeader(“内容编码”);
msgBuild.removeHeader(“接受编码”);
msgBuild.setHeader(csProps.getHttpUrlHdr(),restURL);
msgBuild.setHeader(csProps.getHttpMethodHdr(),httpMethod);
msgBuild.setHeader(csProps.getHttpAuthorizatonHdr(),授权);
//msgBuild.setHeader(csProps.getHttpContentTypeHdr(),contentType);
//msgBuild.setHeader(csProps.getHttpAcceptTypeHdr(),acceptHdr);
outMessage=msgBuild.build();
logger.debug(“****************buildHttpOutboundGatewayRequestEnd*******************************”);
logger.debug(输出消息);
logger.debug(“*************************************************************************************************************”);
返回消息;
}

你知道这里出了什么问题吗?

你的问题是因为你把一条信息包装成另一条

您的
buildMessageForMultipart(multipartMap)是什么是什么

我相信简单的地图作为有效载荷和那些标题就足够了


不确定将一条消息包装到另一条消息有什么意义。

请共享您的
buildmultipartttpoutboundgatewayRequest
returns返回类型为
org.springframework.integration.message
的消息。现在有线索了吗?如果您需要任何其他信息,请告诉我?好的。那么,请分享该方法的代码。您所说的是多部分,因此可能有一些部分不能串行使用,例如消息中的某些头。这就是整个消息不可序列化的原因。无论如何,这看起来很奇怪,您将要向rest服务发送消息objectI已经添加了我的java代码,它为SO问题准备了多部分请求。现在请看一看。您的问题是因为您将一条消息包装到另一条消息。您的
buildMessageForMultipart(multipartMap)是什么是什么?我相信简单的地图作为有效载荷和那些标题就足够了。不确定将一条消息包装到另一条消息有什么意义!你说得对。将一条信息包装成另一条信息是罪魁祸首+1用于快速指出缺陷。