0
如何從Response.class中獲取資源URI路徑/位置?當我用這樣的Apache CXF客戶端API調用我的寧靜服務時:REST - 從響應中獲取資源URI(NOT ClientResponse)
Response res = resource.post(object);
我找回JAX-RS響應類型。 CXF並不像澤西島或者RestEasy那樣自己實現響應。那麼如何從Response.class中獲取URI,我在哪裏創建了我的對象?
在澤西我正在處理ClientResponse.class。在那裏我可以處理這個:
res.getLocation();
RestEasy也有一個ClientResponse.class以及我可以處理像澤西島一樣的問題。通過getMetadata()
/**
* Get the location.
*
* @return the location, otherwise <code>null</code> if not present.
*/
public URI getLocation() {
String l = getHeaders().getFirst("Location");
return (l != null) ? URI.create(l) : null;
}
的JAX-RS響應提供標題信息:
它不適用於Jersey 2.8。標題中沒有URI。這可能是因爲重定向? – 2014-05-21 07:15:46