org.apache.cxf.jaxrs.client.WebClient.invoke()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(7.0k)|赞(0)|评价(0)|浏览(151)

本文整理了Java中org.apache.cxf.jaxrs.client.WebClient.invoke()方法的一些代码示例,展示了WebClient.invoke()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebClient.invoke()方法的具体详情如下:
包路径:org.apache.cxf.jaxrs.client.WebClient
类名称:WebClient
方法名:invoke

WebClient.invoke介绍

[英]Does HTTP invocation
[中]HTTP调用

代码示例

代码示例来源:origin: apache/cxf

/**
 * Does HTTP POST invocation and returns typed response object
 * @param body request body, can be null
 * @param responseClass expected type of response object
 * @return typed object, can be null. Response status code and headers
 *         can be obtained too, see Client.getResponse()
 */
public <T> T post(Object body, Class<T> responseClass) {
  return invoke(HttpMethod.POST, body, responseClass);
}

代码示例来源:origin: apache/cxf

/**
 * Does HTTP PUT invocation and returns typed response object
 * @param body request body, can be null
 * @param responseClass expected type of response object
 * @return typed object, can be null. Response status code and headers
 *         can be obtained too, see Client.getResponse()
 */
public <T> T put(Object body, Class<T> responseClass) {
  return invoke(HttpMethod.PUT, body, responseClass);
}

代码示例来源:origin: org.apache.cxf/cxf-rt-rs-client

/**
 * Does HTTP GET invocation and returns typed response object
 * @param responseType generic response type
 * @return typed object, can be null. Response status code and headers
 *         can be obtained too, see Client.getResponse()
 */
public <T> T get(GenericType<T> responseType) {
  return invoke(HttpMethod.GET, null, responseType);
}

代码示例来源:origin: org.apache.cxf/cxf-rt-rs-client

/**
 * Does HTTP POST invocation
 * @param body request body, can be null
 * @return JAXRS Response
 */
public Response post(Object body) {
  return invoke(HttpMethod.POST, body);
}

代码示例来源:origin: org.apache.cxf/cxf-rt-rs-client

/**
 * Does HTTP DELETE invocation
 * @return JAXRS Response
 */
public Response delete() {
  return invoke(HttpMethod.DELETE, null);
}

代码示例来源:origin: org.apache.cxf/cxf-bundle-jaxrs

/**
 * Does HTTP PUT invocation and returns typed response object
 * @param body request body, can be null
 * @param responseClass expected type of response object
 * @return typed object, can be null. Response status code and headers 
 *         can be obtained too, see Client.getResponse()
 */
public <T> T put(Object body, Class<T> responseClass) {
  return invoke("PUT", body, responseClass);
}

代码示例来源:origin: org.apache.cxf/cxf-bundle-jaxrs

/**
 * Does HTTP DELETE invocation
 * @return JAXRS Response
 */
public Response delete() {
  return invoke("DELETE", null);
}

代码示例来源:origin: org.apache.cxf/cxf-bundle-jaxrs

/**
 * Does HTTP PUT invocation and returns typed response object
 * @param body request body, can be null
 * @param responseType generic response type
 * @return typed object, can be null. Response status code and headers 
 *         can be obtained too, see Client.getResponse()
 */
public <T> T put(Object body, GenericType<T> responseType) {
  return invoke("PUT", body, responseType);
}

代码示例来源:origin: apache/cxf

/**
 * Does HTTP PUT invocation
 * @param body request body, can be null
 * @return JAXRS Response
 */
public Response put(Object body) {
  return invoke(HttpMethod.PUT, body);
}

代码示例来源:origin: apache/cxf

@Override
public <T> T method(String method, Entity<?> entity, GenericType<T> genericType) {
  return wc.invoke(method, entity, genericType);
}

代码示例来源:origin: org.apache.cxf/cxf-rt-rs-client

/**
 * Does HTTP PUT invocation
 * @param body request body, can be null
 * @return JAXRS Response
 */
public Response put(Object body) {
  return invoke(HttpMethod.PUT, body);
}

代码示例来源:origin: org.apache.cxf/cxf-rt-rs-client

/**
 * Does HTTP GET invocation
 * @return JAXRS Response
 */
public Response get() {
  return invoke(HttpMethod.GET, null);
}

代码示例来源:origin: org.apache.cxf/cxf-rt-rs-client

/**
 * Does HTTP PUT invocation and returns typed response object
 * @param body request body, can be null
 * @param responseClass expected type of response object
 * @return typed object, can be null. Response status code and headers
 *         can be obtained too, see Client.getResponse()
 */
public <T> T put(Object body, Class<T> responseClass) {
  return invoke(HttpMethod.PUT, body, responseClass);
}

代码示例来源:origin: apache/cxf

/**
 * Does HTTP HEAD invocation
 * @return JAXRS Response
 */
public Response head() {
  return invoke(HttpMethod.HEAD, null);
}

代码示例来源:origin: apache/cxf

/**
 * Does HTTP PUT invocation and returns typed response object
 * @param body request body, can be null
 * @param responseType generic response type
 * @return typed object, can be null. Response status code and headers
 *         can be obtained too, see Client.getResponse()
 */
public <T> T put(Object body, GenericType<T> responseType) {
  return invoke(HttpMethod.PUT, body, responseType);
}

代码示例来源:origin: apache/cxf

@Test
public void testPostBookXsiType() throws Exception {
  String address = "http://localhost:" + PORT + "/the/thebooksxsi/bookstore/books/xsitype";
  JAXBElementProvider<Book> provider = new JAXBElementProvider<>();
  provider.setExtraClass(new Class[]{SuperBook.class});
  provider.setJaxbElementClassNames(Collections.singletonList(Book.class.getName()));
  WebClient wc = WebClient.create(address, Collections.singletonList(provider));
  wc.accept("application/xml");
  wc.type("application/xml");
  SuperBook book = new SuperBook("SuperBook2", 999L, true);
  Book book2 = wc.invoke("POST", book, Book.class, Book.class);
  assertEquals("SuperBook2", book2.getName());
}

代码示例来源:origin: apache/cxf

@Test
public void testReplaceBookMistypedCTAndHttpVerb2() throws Exception {
  String endpointAddress = "http://localhost:" + PORT + "/bookstore/books2/mistyped";
  WebClient wc = WebClient.create(endpointAddress,
                  Collections.singletonList(new ReplaceBodyFilter()));
  wc.accept("text/mistypedxml").header("THEMETHOD", "PUT");
  Book book = wc.invoke("GET", null, Book.class);
  assertEquals(561L, book.getId());
}

代码示例来源:origin: apache/cxf

@Test
public void testReplaceBookMistypedCTAndHttpVerb() throws Exception {
  String endpointAddress = "http://localhost:" + PORT + "/bookstore/books2/mistyped";
  WebClient wc = WebClient.create(endpointAddress,
                  Collections.singletonList(new ReplaceBodyFilter()));
  wc.accept("text/mistypedxml").type("text/xml").header("THEMETHOD", "PUT");
  Book book = wc.invoke("DELETE", new Book("book", 555L), Book.class);
  assertEquals(561L, book.getId());
}
@Test

代码示例来源:origin: apache/cxf

@Test
public void testDeleteWithBody() throws Exception {
  String address = "http://localhost:" + PORT + "/bookstore/deletebody";
  WebClient wc = WebClient.create(address);
  wc.type("application/xml").accept("application/xml");
  WebClient.getConfig(wc).getRequestContext().put("use.async.http.conduit", true);
  Book book = wc.invoke("DELETE", new Book("Delete", 123L), Book.class);
  assertEquals("Delete", book.getName());
  wc.close();
}

代码示例来源:origin: apache/cxf

@Test
public void testRetrieveBookCustomMethodAsyncSync() throws Exception {
  String address = "http://localhost:" + PORT + "/bookstore/retrieve";
  WebClient wc = WebClient.create(address);
  // Setting this property is not needed given that
  // we have the async conduit loaded in the test module:
  // WebClient.getConfig(wc).getRequestContext().put("use.async.http.conduit", true);
  wc.type("application/xml").accept("application/xml");
  Book book = wc.invoke("RETRIEVE", new Book("Retrieve", 123L), Book.class);
  assertEquals("Retrieve", book.getName());
  wc.close();
}

相关文章

WebClient类方法