本文整理了Java中org.apache.cxf.jaxrs.client.WebClient.client()
方法的一些代码示例,展示了WebClient.client()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebClient.client()
方法的具体详情如下:
包路径:org.apache.cxf.jaxrs.client.WebClient
类名称:WebClient
方法名:client
[英]Converts object to Client
[中]将对象转换为客户端
代码示例来源:origin: apache/cxf
/**
* Creates WebClient, baseURI will be set to Client currentURI
* @param object existing client object
*/
public static WebClient fromClientObject(Object object) {
Client client = client(object);
return client == null ? null : fromClient(client, false);
}
代码示例来源:origin: apache/cxf
@PostConstruct
public void verifyWebClient() {
if (!ignoreJaxrsClient) {
if (webClient == null) {
throw new RuntimeException();
}
WebClient.client(webClient).accept("application/xml");
}
}
代码示例来源:origin: apache/cxf
protected String getCurrentEndpointAddress(Object client) {
String currentBaseURI = WebClient.client(client).getBaseURI().toString();
String currentURI = WebClient.client(client).getCurrentURI().toString();
assertTrue(currentURI.startsWith(currentBaseURI));
return currentBaseURI;
}
代码示例来源:origin: apache/cxf
@Test
public void testUserModelInterfaceOneWay() throws Exception {
BookStoreNoAnnotationsInterface proxy =
JAXRSClientFactory.createFromModel("http://localhost:" + PORT + "/usermodel2",
BookStoreNoAnnotationsInterface.class,
"classpath:org/apache/cxf/systest/jaxrs/resources/resources2.xml", null);
proxy.pingBookStore();
assertEquals(202, WebClient.client(proxy).getResponse().getStatus());
}
代码示例来源:origin: apache/cxf
@Test
public void testEmptyPostProxy() throws Exception {
BookStore store = JAXRSClientFactory.create("http://localhost:" + PORT, BookStore.class);
store.emptypost();
assertEquals(204, WebClient.client(store).getResponse().getStatus());
}
代码示例来源:origin: apache/cxf
@Test
public void testOnewayProxy() throws Exception {
BookStore proxy = JAXRSClientFactory.create("http://localhost:" + PORT, BookStore.class);
proxy.onewayRequest();
assertEquals(202, WebClient.client(proxy).getResponse().getStatus());
}
代码示例来源:origin: apache/cxf
@Test(expected = BadRequestException.class)
public void testJwsJwkPlainTextHMacHttpHeadersModified() throws Exception {
String address = "https://localhost:" + PORT + "/jwsjwkhmacHttpHeaders";
BookStore bs = createJwsBookStore(address, null, true, true);
WebClient.client(bs).header("Modify", "true");
bs.echoText("book");
}
@Test
代码示例来源:origin: apache/cxf
@Test
public void testProxyEmtpyResponse() throws Exception {
BookStore localProxy = JAXRSClientFactory.create("local://books", BookStore.class);
assertNull(localProxy.getEmptyBook());
assertEquals(204, WebClient.client(localProxy).getResponse().getStatus());
}
代码示例来源:origin: apache/cxf
@Test
public void testEchoGenericSuperBookCollectionProxy2JsonType() throws Exception {
String endpointAddress =
"http://localhost:" + PORT + "/webapp/genericstore2type";
GenericBookStoreSpring2 proxy = JAXRSClientFactory.create(endpointAddress,
GenericBookStoreSpring2.class, Collections.singletonList(new JacksonJsonProvider()));
WebClient.client(proxy).type("application/json").accept("application/json");
List<SuperBook2> books =
proxy.echoSuperBookTypeCollection(Collections.singletonList(new SuperBook2("Super", 124L, true)));
assertEquals(124L, books.get(0).getId());
assertTrue(books.get(0).isSuperBook());
}
代码示例来源:origin: apache/cxf
private void doGetBookProxyClient(String address, String username, String password, int expectedStatus)
throws BookNotFoundFault {
SecureBookInterface books = JAXRSClientFactory.create(address, SecureBookInterface.class,
username, password, null);
Book b = books.getThatBook();
assertEquals(123, b.getId());
Response r = WebClient.client(books).getResponse();
assertEquals(expectedStatus, r.getStatus());
}
代码示例来源:origin: apache/cxf
@Test
public void testEchoGenericSuperBookCollectionProxy2Json() throws Exception {
String endpointAddress =
"http://localhost:" + PORT + "/webapp/genericstore2";
GenericBookStoreSpring2 proxy = JAXRSClientFactory.create(endpointAddress,
GenericBookStoreSpring2.class, Collections.singletonList(new JacksonJsonProvider()));
WebClient.client(proxy).type("application/json").accept("application/json");
List<SuperBook> books =
proxy.echoSuperBookCollection(Collections.singletonList(new SuperBook("Super", 124L, true)));
assertEquals(124L, books.get(0).getId());
assertTrue(books.get(0).isSuperBook());
}
代码示例来源:origin: apache/cxf
@Test
public void testProxyEmptyResponseDirectDispatch() throws Exception {
BookStore localProxy = JAXRSClientFactory.create("local://books", BookStore.class);
WebClient.getConfig(localProxy).getRequestContext().put(LocalConduit.DIRECT_DISPATCH, "true");
assertNull(localProxy.getEmptyBook());
assertEquals(204, WebClient.client(localProxy).getResponse().getStatus());
}
代码示例来源:origin: apache/cxf
@Test
public void testUpdateWithProxy() throws Exception {
BookStore bs = JAXRSClientFactory.create("http://localhost:" + PORT, BookStore.class);
Book book = new Book();
book.setId(888);
bs.updateBook(book);
assertEquals(304, WebClient.client(bs).getResponse().getStatus());
}
代码示例来源:origin: apache/cxf
@Test
public void testThatClientDiscoversServiceProperly() throws Exception {
BookStore bs = JAXRSClientFactory.create("http://localhost:" + PORT, BookStore.class,
"org/apache/cxf/systest/jaxrs/discovery/jaxrs-http-client.xml");
assertEquals("http://localhost:" + PORT, WebClient.client(bs).getBaseURI().toString());
BookWithValidation book = bs.getBook("123");
assertEquals(book.getId(), "123");
}
代码示例来源:origin: apache/cxf
@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());
}
代码示例来源:origin: apache/cxf
private void doTestGetBook123Proxy(String configFile) throws Exception {
BookStore bs = JAXRSClientFactory.create("https://localhost:" + PORT, BookStore.class,
configFile);
// just to verify the interface call goes through CGLIB proxy too
assertEquals("https://localhost:" + PORT, WebClient.client(bs).getBaseURI().toString());
Book b = bs.getSecureBook("123");
assertEquals(b.getId(), 123);
b = bs.getSecureBook("123");
assertEquals(b.getId(), 123);
}
代码示例来源:origin: apache/cxf
@Test
public void testGetBookSubresourceWebClientProxyBean() throws Exception {
WebClient client = WebClient.create("http://localhost:" + PORT + "/test/services/rest");
client.type(MediaType.TEXT_PLAIN_TYPE)
.accept(MediaType.APPLICATION_XML_TYPE, MediaType.TEXT_XML_TYPE);
BookStoreJaxrsJaxws proxy =
JAXRSClientFactory.fromClient(client, BookStoreJaxrsJaxws.class, true);
doTestSubresource(proxy);
BookStoreJaxrsJaxws proxy2 = JAXRSClientFactory.fromClient(
WebClient.client(proxy), BookStoreJaxrsJaxws.class);
doTestSubresource(proxy2);
}
代码示例来源:origin: apache/cxf
@Test
public void testEchoGenericSuperBookProxy2Json() throws Exception {
String endpointAddress =
"http://localhost:" + PORT + "/webapp/genericstore2";
GenericBookStoreSpring2 proxy = JAXRSClientFactory.create(endpointAddress,
GenericBookStoreSpring2.class, Collections.singletonList(new JacksonJsonProvider()));
WebClient.getConfig(proxy).getHttpConduit().getClient().setReceiveTimeout(1000000000L);
WebClient.client(proxy).type("application/json").accept("application/json");
SuperBook book = proxy.echoSuperBook(new SuperBook("Super", 124L, true));
assertEquals(124L, book.getId());
assertTrue(book.isSuperBook());
}
代码示例来源:origin: apache/cxf
@Test
public void testEchoGenericSuperBookProxy2JsonType() throws Exception {
String endpointAddress =
"http://localhost:" + PORT + "/webapp/genericstore2type";
GenericBookStoreSpring2 proxy = JAXRSClientFactory.create(endpointAddress,
GenericBookStoreSpring2.class, Collections.singletonList(new JacksonJsonProvider()));
WebClient.getConfig(proxy).getHttpConduit().getClient().setReceiveTimeout(1000000000L);
WebClient.client(proxy).type("application/json").accept("application/json");
SuperBook2 book = proxy.echoSuperBookType(new SuperBook2("Super", 124L, true));
assertEquals(124L, book.getId());
assertTrue(book.isSuperBook());
}
代码示例来源:origin: apache/cxf
@Test
public void testGetBook123ProxyToWebClient() throws Exception {
BookStore bs = JAXRSClientFactory.create("https://localhost:" + PORT, BookStore.class,
CLIENT_CONFIG_FILE1);
Book b = bs.getSecureBook("123");
assertEquals(b.getId(), 123);
WebClient wc = WebClient.fromClient(WebClient.client(bs));
wc.path("/bookstore/securebooks/123").accept(MediaType.APPLICATION_XML_TYPE);
Book b2 = wc.get(Book.class);
assertEquals(123, b2.getId());
}
内容来源于网络,如有侵权,请联系作者删除!