2014-10-20 72 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标题。

发送相同请求但没有任何标头时,我的端点成功接收到该文件。