2014-10-20 1 views
1

"우편환"을 사용하여 "form-data"옵션에서 xml 파일을 첨부 파일로 보내고 있습니다. 나는 "multipart/form-data"로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 헤더를 보내지 않아야합니다.

헤더없이 동일한 요청을 보내면 내 끝점에서 파일을 수신했습니다.