Mule ESB and “multipart/form-data”

三世轮回 提交于 2020-01-05 04:49:20

问题


I have a working Web service that allows me to upload a file. I'd like to put Mule 3 in front of it but I have not been successful in getting it to pass along payloads whose MIME type is "multipart/form-data".

Attempts to do so produce a 400 error: "The request sent by the client was syntactically incorrect (Bad Request)."

The following flow (which doesn't accomplish my purpose but serves as a test) works fine, passing along whatever text I POSTed.

<flow name="Flow1" doc:name="Flow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="test/rule_file" mimeType="text/plain" doc:name="HTTP"/>
<http:outbound-endpoint exchange-pattern="request-response" host="localhost" port="8080" path="test/rule_file" mimeType="text/plain" doc:name="HTTP"/>
</flow>

However, when I switch from "text/plain" to "multipart/form-data", it produces the error listed above.

<flow name="Flow1" doc:name="Flow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="test/rule_file" mimeType="multipart/form-data" doc:name="HTTP"/>
<http:outbound-endpoint exchange-pattern="request-response" host="localhost" port="8080" path="test/rule_file" mimeType="multipart/form-data" doc:name="HTTP"/>
</flow>

Can someone point out how I might get this working?


回答1:


It seems you're attempting to build an HTTP proxy: to make it work you would have to copy properties in both request and response phases of the flow and also propagate the path extension that could have been used on the inbound HTTP endpoint.

This is feasible by hand but it's much better to use the ready-made pattern for this:

<pattern:http-proxy name="patternProxy"
    inboundAddress="http://localhost:8081/test/rule_file"
    outboundAddress="http://localhost:8080/test/rule_file" />


来源:https://stackoverflow.com/questions/14751850/mule-esb-and-multipart-form-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!