DefaultClientConfig config = new DefaultClientConfig(); config.getProperties().put(URLConnectionClientHandler.PROPERTY_HTTP_URL_CONNECTION _SET_METHOD_WORKAROUND, true); Client c = Client.create(config); WebResource r = c.resource("http://google.com"); String reponse = r.method("FOOBAR", String.class);
protected void validateIdentityContext(final IdentityContextId identityContextId) throws AuthenticationDeniedException { RestExecutor.executeAndHandleAuthenticationDeniedRuntimeException(() -> { imJaxrsUrlHelper.authentication(identityContextId.getId()) .queryParam(ImJaxrsConstants.PARAM_OMIT_RESPONSE, Boolean.TRUE.toString())// .method(HttpMethod.GET); // get without response return null; }); }
/** * Execute the operation. Failures are raised as IOException subclasses * @param method method to execute * @param resource resource to work against * @param t type to work with * @param <T> type expected * @return an instance of the type T * @throws IOException on any failure */ public <T> T exec(HttpVerb method, WebResource resource, GenericType<T> t) throws IOException { try { Preconditions.checkArgument(t != null); log.debug("{}} {}", method, resource.getURI()); resource.accept(MediaType.APPLICATION_JSON_TYPE); return resource.method(method.getVerb(), t); } catch (ClientHandlerException ex) { throw ExceptionConverter.convertJerseyException(method.getVerb(), resource.getURI().toString(), ex); } catch (UniformInterfaceException ex) { throw UgiJerseyBinding.uprateFaults(method, resource.getURI().toString(), ex); } }
/** * Execute the operation. Failures are raised as IOException subclasses * @param method method to execute * @param resource resource to work against * @param t type to work with * @param <T> type expected * @return an instance of the type T * @throws IOException on any failure */ public <T> T exec(HttpVerb method, WebResource resource, GenericType<T> t) throws IOException { try { Preconditions.checkArgument(t != null); log.debug("{}} {}", method, resource.getURI()); resource.accept(MediaType.APPLICATION_JSON_TYPE); return resource.method(method.getVerb(), t); } catch (ClientHandlerException ex) { throw ExceptionConverter.convertJerseyException(method.getVerb(), resource.getURI().toString(), ex); } catch (UniformInterfaceException ex) { throw UgiJerseyBinding.uprateFaults(method, resource.getURI().toString(), ex); } }