球衣客户端不抛出异常 属性
jersey client not throwing exceptions property
我正在使用 jersey 客户端 post 将数据发送到网络服务。我注意到 Jersey 客户端有一些奇怪的行为。
我正在使用以下代码:
WebResource resource=null;
try {
ClientResponse response = resource.accept(mediaType).post(ClientResponse.class, requestEntity);
System.out.println("Successful response received, statusCode=" + jerseyClientResponse.getStatus());)
} catch (UniformInterfaceException e) {
ClientResponse r = e.getResponse();
System.out.println("Exception from server, statusCode="+r.getStatus());
}
如果服务器 returns 404 状态,我希望球衣抛出 UniformInterfaceException 异常但是当我执行代码时,我收到以下消息:
Successful response received, statusCode=404
谁能告诉我为什么没有抛出 UniformInterfaceException?
我正在使用 jersey 客户端版本 1.18。
提前致谢!
Can anyone tell me why is UniformInterfaceException not getting
thrown?
UniformInterfaceException - if the status of the HTTP response is
greater than or equal to 300 and c is not the type ClientResponse.
使用客户端响应以外的类型来获得所需的结果。
Client client = Client.create();
WebResource webResource = client
.resource("http://google.com/fake/no_url");
Object requestEntity = null;
final String post = webResource.post(String.class, requestEntity);
Exception in thread "main" com.sun.jersey.api.client.UniformInterfaceException: POST http://google.com/fake/no_url returned a response status of 411 Length Required
at com.sun.jersey.api.client.WebResource.handle(WebResource.java:686)
我正在使用 jersey 客户端 post 将数据发送到网络服务。我注意到 Jersey 客户端有一些奇怪的行为。
我正在使用以下代码:
WebResource resource=null;
try {
ClientResponse response = resource.accept(mediaType).post(ClientResponse.class, requestEntity);
System.out.println("Successful response received, statusCode=" + jerseyClientResponse.getStatus());)
} catch (UniformInterfaceException e) {
ClientResponse r = e.getResponse();
System.out.println("Exception from server, statusCode="+r.getStatus());
}
如果服务器 returns 404 状态,我希望球衣抛出 UniformInterfaceException 异常但是当我执行代码时,我收到以下消息:
Successful response received, statusCode=404
谁能告诉我为什么没有抛出 UniformInterfaceException?
我正在使用 jersey 客户端版本 1.18。
提前致谢!
Can anyone tell me why is UniformInterfaceException not getting thrown?
UniformInterfaceException - if the status of the HTTP response is greater than or equal to 300 and c is not the type ClientResponse.
使用客户端响应以外的类型来获得所需的结果。
Client client = Client.create();
WebResource webResource = client
.resource("http://google.com/fake/no_url");
Object requestEntity = null;
final String post = webResource.post(String.class, requestEntity);
Exception in thread "main" com.sun.jersey.api.client.UniformInterfaceException: POST http://google.com/fake/no_url returned a response status of 411 Length Required
at com.sun.jersey.api.client.WebResource.handle(WebResource.java:686)