发送文件到Mule入站端点 [英] Send file to Mule inbound-endpoint

查看:148
本文介绍了发送文件到Mule入站端点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图发送一个带有文件和两个输入到一个Mule入站端点的表单。我有一个自定义处理器,并定义如下的流程:

$ $ p code>< custom-processor class =informa。 app.classifier.transformers.MyfileUploadProcessorname =fileuploadprocessor>< / custom-processor>
< flow name =httpTest>
address =http://tango.privada.informa:11002 / services / fileupload>< / http:inbound-endpoint>
< processor ref =fileuploadprocessor/>
< / flow>

在类MyfileUploadProcessor中:

public类MyfileUploadProcessor实现MessageProcessor {

  @Override 
public MuleEvent进程(MuleEvent事件)抛出MuleException {
/ / TODO自动生成的方法存根
字符串响应=成功;

MuleMessage mulemessage = event.getMessage();

String countryCode = mulemessage.getInboundProperty(username);
String sourceCode = mulemessage.getInboundProperty(password);
InputStream input =(InputStream)mulemessage.getPayload();

...

b




$ b $ $ $ $ $ $ $ $ $&$;< form action = http://tango.privada.informa:11002 / services / fileuploadmethod =post
enctype =multipart / form-data>
< p>国家代码:< input type =textname =username/>< / p>
< p>源代码:< input type =textname =password/>< / p>
< p>档案:< input type =filename =payload/>< / p>
< p>< input type =submitname =submitvalue =submit/>
< input type =resetname =resetvalue =reset>< / p>
< / form>

< / body>
< / html>

问题是我无法从mulemessage的有效载荷创建一个文件,知道如何获得形式输入的价值...我做错了什么?任何线索?



提前致谢 您需要配置HTTP连接器使用 org.mule.transport.http.HttpMultipartMuleMessageFactory 来处理 multipart / form-data HTTP POST。



为此,请将以下内容添加到您的配置中:

 < http:连接器名称=httpConnector> 
< service-overrides messageFactory =org.mule.transport.http.HttpMultipartMuleMessageFactory/>
< / http:connector>

有了这个,有效载荷表格字段将成为Mule消息的流式有效载荷,所有其他字段值将位于入站附件中(任何部分头将位于入站标头中)。


I'm trying to send a form with a file and two inputs to an Mule inbound-endpoint. I've got a custom-processor, and a flow defined like that:

<custom-processor class="informa.app.classifier.transformers.MyfileUploadProcessor" name="fileuploadprocessor"></custom-processor>
<flow name="httpTest">
    <http:inbound-endpoint
                    address="http://tango.privada.informa:11002/services/fileupload"></http:inbound-endpoint>
    <processor ref="fileuploadprocessor"/>
</flow>

In the class MyfileUploadProcessor:

public class MyfileUploadProcessor implements MessageProcessor {

    @Override
    public MuleEvent process(MuleEvent event) throws MuleException {
        // TODO Auto-generated method stub
        String response = "success";

        MuleMessage mulemessage = event.getMessage();

        String countryCode = mulemessage.getInboundProperty("username");
        String sourceCode = mulemessage.getInboundProperty("password");
        InputStream input = (InputStream) mulemessage.getPayload();

...

And to test, a simple html:

<form action="http://tango.privada.informa:11002/services/fileupload" method="post"
enctype="multipart/form-data">
   <p>Country Code :<input type="text" name="username" /></p>
   <p>Source Code :<input type="text" name="password" /></p>
   <p>File :<input type="file" name="payload" /></p>
   <p><input type="submit" name="submit" value="submit" />
<input type="reset" name="reset" value="reset"></p>
</form>

</body>
</html>

The issue is I can't create a file from the payload of the mulemessage and I don't know how to get the value of the inputs in the form...what I'm doing wrong? any clues?

Thanks in advance

解决方案

You need to configure the HTTP connector to use the org.mule.transport.http.HttpMultipartMuleMessageFactory in order to handle multipart/form-data HTTP POSTs.

For this, add the following to your configuration:

<http:connector name="httpConnector">
    <service-overrides messageFactory="org.mule.transport.http.HttpMultipartMuleMessageFactory"/>
</http:connector>

With this in place, the payload form field will become the streaming payload of the Mule message and all the other fields values will be in inbound attachments (any part header will be in inbound headers).

这篇关于发送文件到Mule入站端点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆