2

我正在编写一个使用 Jersey 实现一些 Web 服务的骡子应用程序。我想上传一个文件。我写了以下骨架

@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";
}

如果两个 FormDataParam 参数被注释掉,我就可以卷曲到服务器并获得预期的响应。在未注释参数的情况下,以下 curl (与以前相同)得到一个 400 错误作为响应。

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

我需要做什么才能成功地将文件发布到此代码并处理它?

4

1 回答 1

0

这已通过http://www.mulesoft.org/jira/browse/MULE-5628修复

于 2011-12-02T22:45:37.050 回答