java - 使用 Jersey 客户端发送原始 XML?

标签 java xml jersey

String xmlString = "<a>test</a>
WebResource resource = Client.create().resource("http://somehost.com")
resource.put(ClientResponse.class, xmlString)

上面的东西如何工作?我没有在另一端获得应用程序/xml header 的内容类型。

最佳答案

更新

您可以为看跌期权执行以下操作:

WebResource resource = Client.create().resource("http://somehost.com");
ClientResponse response = resource.type("application/xml").put(ClientResponse.class, "<a>test</a>");

您可以执行以下操作:

WebResource resource = Client.create().resource("http://somehost.com");
ClientResponse response = resource.accept("application/xml").get(ClientResponse.class);

关于java - 使用 Jersey 客户端发送原始 XML?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6125837/

相关文章:

xml - 将 XSD 文件链接到 XML

java - Jersey :可以从父类继承路径

web-services - 如何在 REST Web 服务中传递自定义对象

java - HTML 到 Servlet 到 JSP 动态表

java - jsr-303 实体验证错误未在 jsp 中显示

xml - 将数据从数据库导出到 XML 文件

c# - 如何使用 Linq 解析 XML 文件 - 后代

java - 如何从 JerseyTest 子类访问 Spring Bean

java - 为 WebView 强制移动版本的网站

java - 带有 Google Cloud Endpoints 的 .api 文件 - 如何自定义