One more option "/post" ? So is it "post", "../post", or "/post" ?
Sergey On 28/04/15 10:26, Sergey Beryozkin wrote:
Hi Thanks for this analysis, I'm looking at the docs, example https://jax-rs-spec.java.net/nonav/2.0-rev-a/apidocs/javax/ws/rs/core/Response.html#getLink(java.lang.String) it says: "A relative link is resolved with respect to the actual request URI that produced this response". What is the link value in your case, "../post" or "post" ? Thanks, Sergey On 28/04/15 07:19, ellen wrote:Hi all, I'm using response getLink method from CXF. The code is: private Map<String, Link> getAllLinks() { List linkValues = metadata.get(HttpHeaders.LINK); if (linkValues == null) { return Collections.emptyMap(); } else { Map<String, Link> links = new LinkedHashMap<String, Link>(); for (Object o : linkValues) { Link link = o instanceof Link ? (Link)o : Link.valueOf(o.toString()); if (!link.getUri().isAbsolute()) { *URI requestURI = URI.create((String)outMessage.get(Message.REQUEST_URI));* link = Link.fromLink(link).baseUri(requestURI).build(); } links.put(link.getRel(), link); } return links; } } But from the code you can see therequestURI comes from Message REQUEST_URI. If my request uri is http://www.test.com/resource/get then I continue use the link to invoke like this: Link link = response.getLink(linkName); response = client.invocation(link).post(null); The url which response use is joined like this: http://www.test.com/resource/get/post, but this http://www.test.com/resource/get/post is not exist (correct lin should be http://www.test.com/resource/post). So I think this is not good. I'm looking at Jersey getLink method, and found they use: URI result = baseUri.resolve(refUri); to get Request url, and I found the result is correct for me. Could you please take a look this issue? Thanks a lot! -- View this message in context: http://cxf.547215.n5.nabble.com/The-logic-of-Response-getAllLinks-method-is-not-good-tp5756610.html Sent from the cxf-dev mailing list archive at Nabble.com.
-- Sergey Beryozkin Talend Community Coders http://coders.talend.com/ Blog: http://sberyozkin.blogspot.com
