/** * Creates WebClient * @param baseAddress baseAddress */ public static WebClient create(String baseAddress) { JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean(); bean.setAddress(baseAddress); return bean.createWebClient(); }
/** * Creates WebClient * @param baseAddress baseAddress */ public static WebClient create(String baseAddress) { JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean(); bean.setAddress(baseAddress); return bean.createWebClient(); }
/** * Creates WebClient * @param baseAddress baseAddress */ public static WebClient create(String baseAddress) { JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean(); bean.setAddress(baseAddress); return bean.createWebClient(); }
JAXRSClientFactoryBean factoryBean = new JAXRSClientFactoryBean(); factoryBean.setAddress("http://localhost:6061/services"); MyServiceInterface documentCapture = factoryBean.create(MyServiceInterface.class); Client client = ClientProxy.getClient(documentCapture); client.getRequestContext().put("use.async.http.conduit", Boolean.TRUE);
protected JAXRSClientFactoryBean createBean(String address, FailoverFeature feature) { JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean(); bean.setAddress(address); List<Feature> features = new ArrayList<>(); features.add(feature); bean.setFeatures(features); return bean; }
static JAXRSClientFactoryBean getBean(String baseAddress, String configLocation) { JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean(); if (configLocation != null) { SpringBusFactory bf = new SpringBusFactory(); Bus bus = bf.createBus(configLocation); bean.setBus(bus); } bean.setAddress(baseAddress); return bean; }
protected JAXRSClientFactoryBean createBean(String address, FailoverFeature feature) { JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean(); bean.setAddress(address); List<AbstractFeature> features = new ArrayList<>(); features.add(feature); bean.setFeatures(features); return bean; }
static JAXRSClientFactoryBean getBean(String baseAddress, String configLocation) { JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean(); if (configLocation != null) { SpringBusFactory bf = new SpringBusFactory(); Bus bus = bf.createBus(configLocation); bean.setBus(bus); } bean.setAddress(baseAddress); return bean; }
static JAXRSClientFactoryBean getBean(String baseAddress, String configLocation) { JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean(); if (configLocation != null) { SpringBusFactory bf = new SpringBusFactory(); Bus bus = bf.createBus(configLocation); bean.setBus(bus); } bean.setAddress(baseAddress); return bean; }
private WebClient createClient(String address, String username, String password) { JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean(); bean.setAddress(address); bean.setUsername(username); bean.setPassword(password); bean.getOutInterceptors().add(new LoggingOutInterceptor()); bean.getInInterceptors().add(new LoggingInInterceptor()); WebClient wc = bean.createWebClient(); WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(1000000L); return wc; }
private WebClient createRsWebClient(String address, ClientAccessToken at, String clientContext) { JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean(); bean.setAddress(address); SpringBusFactory bf = new SpringBusFactory(); URL busFile = JAXRSOAuth2TlsTest.class.getResource(clientContext); Bus springBus = bf.createBus(busFile.toString()); bean.setBus(springBus); WebClient wc = bean.createWebClient(); wc.accept(MediaType.APPLICATION_XML); wc.authorization(at); return wc; }
private WebClient createWebClient(String address) { JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean(); bean.setAddress(address); SpringBusFactory bf = new SpringBusFactory(); URL busFile = JAXRSOAuth2Test.class.getResource("client.xml"); Bus springBus = bf.createBus(busFile.toString()); bean.setBus(springBus); WebClient wc = bean.createWebClient(); wc.type(MediaType.APPLICATION_FORM_URLENCODED).accept(MediaType.APPLICATION_JSON); return wc; }
private WebClient createOAuth2WebClient(String address) { JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean(); bean.setAddress(address); SpringBusFactory bf = new SpringBusFactory(); URL busFile = JAXRSOAuth2TlsTest.class.getResource("client.xml"); Bus springBus = bf.createBus(busFile.toString()); bean.setBus(springBus); WebClient wc = bean.createWebClient(); wc.type(MediaType.APPLICATION_FORM_URLENCODED).accept(MediaType.APPLICATION_JSON); return wc; } private WebClient createDynRegWebClient(String address) {
@Test public void testGetStringList() throws Exception { String address = "http://localhost:" + PORT; JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean(); bean.setProvider(new BookStore.StringListBodyReaderWriter()); bean.setAddress(address); bean.setResourceClass(BookStore.class); BookStore store = bean.create(BookStore.class); List<String> str = store.getBookListArray(); assertEquals("Good book", str.get(0)); }
@Test public void testBookWithSpaceProxyPathUrlEncodedSemicolonOnly() throws Exception { JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean(); bean.setServiceClass(BookStore.class); bean.setAddress("http://localhost:" + PORT); bean.getProperties(true).put("url.encode.client.parameters", "true"); bean.getProperties(true).put("url.encode.client.parameters.list", ";"); BookStore store = bean.create(BookStore.class); Book book = store.getBookWithSemicolon("123;:", "custom;:header"); assertEquals(123L, book.getId()); assertEquals("CXF in Action%3B:", book.getName()); }
@Test public void testEmptyPostProxy2() throws Exception { String address = "http://localhost:" + PORT; JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean(); bean.setAddress(address); bean.setResourceClass(BookStore.class); BookStore store = bean.create(BookStore.class); store.emptypostNoPath(); assertEquals(204, WebClient.client(store).getResponse().getStatus()); }
@Test public void testBookWithSpaceProxyPathUrlEncoded() throws Exception { JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean(); bean.setServiceClass(BookStore.class); bean.setAddress("http://localhost:" + PORT); bean.setProperties(Collections.<String, Object>singletonMap("url.encode.client.parameters", Boolean.TRUE)); BookStore store = bean.create(BookStore.class); Book book = store.getBookWithSemicolon("123;:", "custom;:header"); assertEquals(123L, book.getId()); assertEquals("CXF in Action%3B%3A", book.getName()); }
@Test public void testGetStringArray() throws Exception { String address = "http://localhost:" + PORT; JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean(); bean.setProvider(new BookStore.StringArrayBodyReaderWriter()); bean.setAddress(address); bean.setResourceClass(BookStore.class); BookStore store = bean.create(BookStore.class); String[] str = store.getBookStringArray(); assertEquals("Good book", str[0]); }
@Test public void testOtherInterceptorDrainingStream() throws Exception { String baseAddress = "http://localhost:" + PORT + "/test/services/rest"; JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean(); bean.setAddress(baseAddress); bean.getInInterceptors().add(new TestStreamDrainInterptor()); WebClient client = bean.createWebClient(); client.path("/bookstore/123").accept(MediaType.APPLICATION_XML_TYPE); Book b = client.get(Book.class); assertEquals(123, b.getId()); assertEquals("CXF in Action", b.getName()); }
@Test public void testGetBook123UserModelAuthorize() throws Exception { JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean(); bean.setAddress("http://localhost:" + PORT + "/usermodel/bookstore/books"); bean.setUsername("Barry"); bean.setPassword("password"); bean.setModelRef("classpath:org/apache/cxf/systest/jaxrs/resources/resources.xml"); WebClient proxy = bean.createWebClient(); proxy.path("{id}/authorize", 123); Book book = proxy.get(Book.class); assertEquals(123L, book.getId()); }