2014-10-20 80 views
1

我使用Postman在「form-data」選項下以附件形式發送xml文件。 我加入的請求標頭「內容類型」爲「多/表單數據」修改端點以接收XML文件

enter image description here

但我的終點是沒有得到的XML文件。我的端點如何接收xml文件?

@PUT 
@Path("/{param1}/{param2}") 
@Consumes(MediaType.APPLICATION_XML) 
@Produces(MediaType.APPLICATION_JSON) 
public Response receiveXmlFile(List<Identifier> identifierList, 
             @PathParam("param1") String param1, 
             @PathParam("param2") String param2, 

             @FormParam("xmlFile") File xmlFile) 
) 
{ 
    try { 
     return Response.status(Response.Status.OK).entity(readXmlFile(xmlFile)).build(); 
    } catch (Exception e) { 
     return Response.status(Response.Status.INTERNAL_SERVER_ERROR).header("error", e.getMessage()).build(); 
    } 
} 

回答

1

解決方法是不發送郵遞員的multipart/form-data標題。

發送相同請求但沒有任何標頭時,我的端點成功接收到該文件。