本文整理了Java中org.apache.cxf.jaxrs.client.WebClient.postCollection()
方法的一些代码示例,展示了WebClient.postCollection()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebClient.postCollection()
方法的具体详情如下:
包路径:org.apache.cxf.jaxrs.client.WebClient
类名称:WebClient
方法名:postCollection
[英]Posts a collection of typed objects
[中]发布类型化对象的集合
代码示例来源:origin: stackoverflow.com
WebClient client = WebClient.create("http://myserver/services/test/postdata3");
client.type("multipart/mixed").accept("application/json");
List<Attachment> atts = new LinkedList<Attachment>();
atts.add(new Attachment("testItem1", "application/json", t1));
atts.add(new Attachment("testItem2", "application/json", t2));
javax.ws.rs.core.Response s = client.postCollection(atts, Attachment.class);
System.out.println(s.getStatus());
代码示例来源:origin: apache/cxf
private void doTestNullPart(String address) throws Exception {
WebClient client = WebClient.create(address);
client.type("multipart/form-data").accept("text/plain");
List<Attachment> atts = new LinkedList<>();
atts.add(new Attachment("somepart", "text/plain", "hello there"));
Response r = client.postCollection(atts, Attachment.class);
assertEquals(Response.Status.OK.getStatusCode(), r.getStatus());
assertEquals("nobody home", IOUtils.readStringFromStream((InputStream)r.getEntity()));
}
代码示例来源:origin: apache/cxf
@Test
public void testThatValidationConstraintsAreViolatedWithBooks() {
final Response r = createWebClient("/bookstore/books/directmany").type("text/xml").postCollection(
Collections.singletonList(new BookWithValidation("BeanVal")), BookWithValidation.class);
assertEquals(Status.BAD_REQUEST.getStatusCode(), r.getStatus());
}
代码示例来源:origin: apache/cxf
@Test
public void testNullableParamsPrimitive() throws Exception {
String address = "http://localhost:" + PORT + "/bookstore/books/testnullpartprimitive";
WebClient client = WebClient.create(address);
client.type("multipart/form-data").accept("text/plain");
List<Attachment> atts = new LinkedList<>();
atts.add(new Attachment("somepart", "text/plain", "hello there"));
Response r = client.postCollection(atts, Attachment.class);
assertEquals(Response.Status.OK.getStatusCode(), r.getStatus());
assertEquals((Integer)0, Integer.valueOf(IOUtils.readStringFromStream((InputStream)r.getEntity())));
}
代码示例来源:origin: apache/cxf
@Test
public void testPostCollectionGetBooksWebClient() throws Exception {
String endpointAddress =
"http://localhost:" + PORT + "/bookstore/collections3";
WebClient wc = WebClient.create(endpointAddress);
wc.accept("application/xml").type("application/xml");
Book b1 = new Book("CXF in Action", 123L);
Book b2 = new Book("CXF Rocks", 124L);
List<Book> books = new ArrayList<>();
books.add(b1);
books.add(b2);
Book book = wc.postCollection(books, Book.class, Book.class);
assertEquals(200, wc.getResponse().getStatus());
assertNotSame(b1, book);
assertEquals(b1.getName(), book.getName());
}
内容来源于网络,如有侵权,请联系作者删除!