我创建了一个使用jsonobject的webservice,如下所示:
@POST
@Consumes({MediaType.APPLICATION_JSON})
@Produces(MediaType.APPLICATION_OCTET_STREAM)
@Path("/postjson")
public Response postFile(JSONObject fichier) throws Exception{
System.out.println("Filename = "+fichier.get("file"));
return download( fichier.get("file").toString());
}
当我开始执行客户端时,我得到了500个错误代码
JSONObject document=new JSONObject();
document.put("file", "bbg.pdf");
javax.ws.rs.client.Client client = ClientBuilder.newClient();
WebTarget webTarget = client.target("http://localhost:7001/WSTest/webresources/files/")
.path("postjson");
Response response=webTarget.request()
.post(Entity.json(document));
System.out.println(response.getStatus());
暂无答案!
目前还没有任何答案,快来回答吧!