1

我们有 apache CXF 应用程序可以在 Windows 上运行,但不能在 Ubuntu 上运行。GET 请求有效,但 POST 请求不接收消息正文。接收消息的上传类:

@Path("/api/user/{userId}")
public class Upload {
  @POST
  @Path("upload")
  @Produces(MediaType.APPLICATION_JSON)
  @Consumes(MediaType.MULTIPART_FORM_DATA)
  public FileRecord upload(@PathParam("userId") String userId, 
                           @QueryParam("key") String accessKey,
                           @Multipart(value="FileRecord", type=MediaType.APPLICATION_JSON) FileRecord fileRecord,
                           @Multipart(value="BodyRecord", type=MediaType.APPLICATION_OCTET_STREAM) InputStream body) {    

fileRecord 在 ubuntu 上为空,但在 Windows 上没问题。

我们发送的消息:(标题)

POST http://192.168.1.71:9000/api/user/tdq/upload HTTP/1.1
Accept-Encoding: gzip,deflate
Accept: application/json
MIME-Version: 1.0
content-type: multipart/form-data;boundary="123"
Content-Length: 443
Host: 192.168.1.71:9000
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)

(身体)

--123
Content-Disposition: form-data; name="FileRecord"
Content-Type: application/json
Content-ID: FileRecord

{"FileRecord":{"name":"UploadTest"}}
--123
Content-Disposition: form-data; name="BodyRecord"
Content-Type: application/octet-stream
Content-ID: BodyRecord

This is a body
--123
4

0 回答 0