问题
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