开发者

Send raw XML using jersey client?

开发者 https://www.devze.com 2023-03-08 03:06 出处:网络
String xmlString = \"<a>test</a> WebResource resource = Client.create().resource(\"http://somehost.com\")
String xmlString = "<a>test</a>
WebResource resource = Client.create().resource("http://somehost.com")
resource.put(ClientResponse.class, xmlString)

Ho开发者_运维技巧w can something like the above work? I am not getting content-type of application/xml header on the other side.


UPDATE

You could do the following for a put:

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

You could do the following for a get:

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

精彩评论

暂无评论...
验证码 换一张
取 消