2

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?

Tad
  • 517
  • 8
  • 30

1 Answers1

3

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" />
David Dossot
  • 33,403
  • 4
  • 38
  • 72
  • Hi David. Thanks for that reply; it helped. My problem now is that the data doesn't pass through that pattern in the way I expect. I've got a form where the user browses for a file. The file is passed to the Web service that uploads it. When I go directly against the Web service, this works. When I go through that pattern, all backslashes are stripped out of the file path, rendering the name worthless. Is there some configuration that would fix this? – Tad Feb 13 '13 at 21:22
  • Wow that sounds like a nasty bug :( Can you craft a `curl` command that reproduces the problem so I can investigate? – David Dossot Feb 13 '13 at 21:44
  • Well, being new to the Linux world, I'd have to do a bit of research on what that is first. *smile* However, it's not necessary. Upon further investigation, the problem appears to be browser specific; I only see it on IE, so I don't think it's Mule's fault. Thanks for your help. I really appreciate it and would vote up on your answer except that (being new here, also) I don't have any "reputation" yet so it won't let me vote. – Tad Feb 14 '13 at 13:09
  • Oh IE :'( But still the proxy should work even for _this_ browser... I'm curious as to what's happening. Even being know at SO, you should be able to accept my answer. – David Dossot Feb 14 '13 at 19:46