2

I'm writing a mule application that implements some web services using Jersey. I'd like to upload a file. I've written the following skeleton

@POST
@Path("/getHtml")
@Consumes("multipart/form-data")
@Produces("text/plain")
public String getSummaryHtml(
        @FormDataParam("payload") String junk,
        @FormDataParam("x12file") InputStream file
        ) {
    LOG.info("called getSummaryHtml");

    return "got";
}

If the two FormDataParam parameters are commented out, I am able to curl to the server and get the expected response. With the parameters uncommented, the following curl (same one that works previously) gets me a 400 error in response.

curl -v -X POST --form x12file=@MULE-README.txt --form payload=junk http://localhost:8080/jersey/X12ToSummaryHtml/getHtml/

* About to connect() to localhost port 8080 (#0)
*   Trying 127.0.0.1... connected
* Connected to localhost (127.0.0.1) port 8080 (#0)
> POST /jersey/X12ToSummaryHtml/getHtml/ HTTP/1.1
> User-Agent: curl/7.21.3 (i386-redhat-linux-gnu) libcurl/7.21.3 NSS/3.12.10.0 zlib/1.2.5 libidn/1.19 libssh2/1.2.7
> Host: localhost:8080
> Accept: */*
> Content-Length: 2706
> Expect: 100-continue
> Content-Type: multipart/form-data; boundary=----------------------------55b24ac88245
> 
< HTTP/1.1 100 Continue
< Content-Type: text/plain
< Content-Length: 0
< Connection: close
< HTTP/1.1 400 Bad Request
< Content-Type: multipart/form-data; boundary=----------------------------55b24ac88245
< Date: Sat, 25 Jun 2011 01:29:10 MDT
< Server: Mule Core/3.1.1
< Expires: Sat, 25 Jun 2011 01:29:10 MDT
< http.status: 400
< MULE_ENCODING: UTF-8
< Transfer-Encoding: chunked
< Connection: close
< 
* Closing connection #0

What do I need to do to successfully POST a file to this code and process it?

Ben Mathews
  • 2,939
  • 2
  • 19
  • 25
  • I've posted [a fully working/tested sample](http://stackoverflow.com/questions/5772225/trying-to-upload-a-file-to-a-jax-rs-jersey-server/5872112#5872112) several weeks ago. Hope it'll help. – yves amsellem Jun 28 '11 at 12:50
  • Apparently something is wrong with how Mule is passing the message to Jersey. I am getting a MIMEParsingException thrown at. org.jvnet.mimepull.MIMEParser.skipPreamble() line: 313 – Ben Mathews Jun 30 '11 at 20:15
  • I deployed the same Jersey code into a Jetty container and it works fine. Something is broken with the Mule code. – Ben Mathews Jul 01 '11 at 16:26

1 Answers1

0

This was fixed with http://www.mulesoft.org/jira/browse/MULE-5628

Ben Mathews
  • 2,939
  • 2
  • 19
  • 25