如何从 mule 流创建 http/multipart 响应?
存在并设置了 outboundAttachments 和 outboundAttachmentFilenames,但收到的 http 响应不包含任何附件。
我尝试了一个自定义的 java 组件,它使用提供的 Jersey 类来构建多部分响应,但我找不到 mule 响应的工作转换器。
@Override
public Object onCall(MuleEventContext eventContext) throws Exception {
MultiPart multiPart = new MultiPart();
MuleMessage message = eventContext.getMessage();
for (String attachmentName : message.getOutboundAttachmentNames()) {
multiPart.bodyPart(new BodyPart(message.getOutboundAttachment(attachmentName), MediaType.APPLICATION_OCTET_STREAM_TYPE));
}
Response response = Response.status(200).entity(multiPart).type(MultiPartMediaTypes.MULTIPART_MIXED).build();
return response;
}
错误是
Could not find a transformer to transform "SimpleDataType{type=com.sun.jersey.core.spi.factory.ResponseImpl, mimeType='text/xml'}" to "SimpleDataType{type=org.mule.api.transport.OutputHandler, mimeType='*/*'}".
我正在使用 Mule 3.5.0 EE。
最好的问候, 马克
最佳答案
这是一个已知问题,已在 Mule 3.6.0 中修复。
参见:https://www.mulesoft.org/jira/browse/MULE-7885
升级或要求 MuleSoft 为 3.5.x EE 提供向后移植的补丁。
关于java - Mule - 创建 http 多部分响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32328161/