Jersey REST Client:如何将XML文件添加到POST请求的主体中?

Mac*_*rko 3 java xml rest web-services jersey

我的代码到目前为止:

FileReader fileReader = new FileReader("filename.xml");
Client c = Client.create();
WebResource webResource = c.resource("http://localhost:8080/api/resource");
webResource.type("application/xml");
Run Code Online (Sandbox Code Playgroud)

我要发送的内容filename.xmlPOST方法,但我不知道如何将它们添加到请求的身体.我需要帮助,因为在网上我只能找到如何添加Formargs.

提前致谢.

Qwe*_*rky 7

看看Jersey APIWebResource.它为您提供了post一种接受数据的方法.