File Mule 3.7.0:使用新的http连接器和jersey进行多部分文件上载

File Mule 3.7.0:使用新的http连接器和jersey进行多部分文件上载,file,http,upload,jersey,mule,File,Http,Upload,Jersey,Mule,我正在升级一个应用程序,它使用http和jersey将文件上传到Mule 3.7.0,并迁移到新的http实现。在更新之前,我能够使用以下配置上传一个文件 <http:connector name="HttpConnector" > <service-overrides messageFactory="org.mule.transport.http.HttpMuleMessageFactory" sessionHandler="org.mule.sess

我正在升级一个应用程序,它使用http和jersey将文件上传到Mule 3.7.0,并迁移到新的http实现。在更新之前,我能够使用以下配置上传一个文件

<http:connector name="HttpConnector" >
    <service-overrides messageFactory="org.mule.transport.http.HttpMuleMessageFactory"
        sessionHandler="org.mule.session.NullSessionHandler" />
</http:connector>

<flow name="UploadFlow">
    <http:inbound-endpoint address="http://0.0.0.0:8095/sds" connector-ref="HttpConnector"/>
    <jersey:resources>
        <component>
            <spring-object bean="FileUploadResource" />
        </component>
    </jersey:resources>
</flow>
更新的配置如下所示

<http:listener-config name="HttpListenerConfig" host="0.0.0.0" basePath="/sds" port="8095"/>

<flow name="UploadFlow">
    <http:listener config-ref="HttpListenerConfig" path="/*"/>
    <jersey:resources>
        <component>
            <spring-object bean="FileUploadResource" />
        </component>
    </jersey:resources>
</flow>

如果没有日志,很难知道问题出在哪里。然而,为什么要用运动衫呢?您只需使用http连接器即可在多部分请求中上载文件。有关如何生成多部分请求的信息,请查看此页面:


如果您仍然有令人信服的理由继续使用Jersey,请确保Jersey已启用Jersey多部分支持(考虑Jersey已在Mule 3.6中升级)

我通过在http侦听器上设置parseRequest=“false”解决了此问题

<http:listener config-ref="HttpListenerConfig" path="/*" parseRequest="false"/>


您发送的请求是什么样子的?@afelisati请参见上文中的请求标题您是否有意修改边界参数?因为这似乎不对…@afelisatti我已经修改了它们。我从firefox中的调试工具复制了这个。我相信它只是为了查看而压缩的。鼓励链接到外部资源,但是请在链接周围添加上下文,这样您的其他用户就会知道它是什么以及它为什么在那里。始终引用重要链接中最相关的部分,以防无法访问目标站点或永久脱机。
Host: 192.168.29.129:8095
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:42.0) Gecko/20100101 Firefox/42.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: http://192.168.29.129:8090/mule/
Content-Length: 56068
Content-Type: multipart/form-data; boundary=---------------------------   12776546320886
Origin: http://192.168.29.129:8090
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
<http:listener config-ref="HttpListenerConfig" path="/*" parseRequest="false"/>