/** * Replaces the current path with the new value. * @param path new path value. If it starts from "/" then all the current * path starting from the base URI will be replaced, otherwise only the * last path segment will be replaced. Providing a null value is equivalent * to calling back(true) * @return updated WebClient */ public WebClient replacePath(String path) { if (path == null) { return back(true); } back(path.startsWith("/") ? true : false); return path(path); }
/** * Replaces the current path with the new value. * @param path new path value. If it starts from "/" then all the current * path starting from the base URI will be replaced, otherwise only the * last path segment will be replaced. Providing a null value is equivalent * to calling back(true) * @return updated WebClient */ public WebClient replacePath(String path) { if (path == null) { return back(true); } back(path.startsWith("/") ? true : false); return path(path); }
/** * Replaces the current path with the new value. * @param path new path value. If it starts from "/" then all the current * path starting from the base URI will be replaced, otherwise only the * last path segment will be replaced. Providing a null value is equivalent * to calling back(true) * @return updated WebClient */ public WebClient replacePath(String path) { if (path == null) { return back(true); } back(path.startsWith("/") ? true : false); return path(path); }
public void runCodeWebClient() throws Exception { System.out.println("*** Running WebClient initialized from the code ***"); JAXRSClientFactoryBean factoryBean = prepareFactoryBean(); WebClient wc = factoryBean.createWebClient(); wc.accept("application/xml"); String orderId = "1"; for (int i = 1; i <= 3; i++) { wc.path("orderservice").path(orderId); Order ord = wc.get(Order.class); describeOrder(i, ord); wc.back(true); Thread.sleep(2000); } }
private void invoke(int ind) throws Exception { client.type("text/plain").accept("text/plain"); String actualHeaderName = bookHeader + ind; String actualBookName = bookName + ind; MultivaluedMap<String, String> map = client.getHeaders(); map.putSingle("CustomHeader", actualHeaderName); client.headers(map).path("booksecho"); doInvoke(actualBookName, actualHeaderName); // reset current path client.back(true); }
@Test public void testGetBook123WebClientToProxy() throws Exception { WebClient wc = WebClient.create("https://localhost:" + PORT, CLIENT_CONFIG_FILE1); wc.path("/bookstore/securebooks/123").accept(MediaType.APPLICATION_XML_TYPE); Book b = wc.get(Book.class); assertEquals(123, b.getId()); wc.back(true); BookStore bs = JAXRSClientFactory.fromClient(wc, BookStore.class); Book b2 = bs.getSecureBook("123"); assertEquals(b2.getId(), 123); }