On 04/06/2013 10:36, Francesco Chicchiriccò wrote:
Hi all,
I am currently evaluating Wink for a new project.
I have been playing around with some samples and it seems linear to me.
I am not completely convinced, however, of async usage; this is how I
have managed to get it working:
AsyncHttpClient asyncHttpClient = new AsyncHttpClient();
RestClient client = new RestClient(new
AsyncHttpClientConfiguration(asyncHttpClient));
Resource resource =
client.resource("http://services.odata.org/v3/(S(sn4zeecdefwvblk2xxlk425x))/OData/OData.svc/Products");
AtomFeed feed =
resource.contentType("application/atom+xml").accept("application/atom+xml").get(AtomFeed.class);
asyncHttpClient.close();
for (AtomEntry entry : feed.getEntries()) {
System.out.println(entry.getTitle().getValue());
}
Is this the correct usage? Isn't there any way to get something like
Future<AtomFeed> instead?
Moreover, I was also looking for a way to get an InputStream out of a
response, to delay processing: is this possible?
I guess I've found (this seems to work):
RestClient client = new RestClient(new
ApacheHttpClientConfig(new DefaultHttpClient()));
Resource resource =
client.resource("http://localhost:8080/Northwind/Northwind.svc/Categories(1)");
ClientResponse response =
resource.accept(MediaType.APPLICATION_ATOM_XML).get();
InputStream is = response.getEntity(InputStream.class);
System.out.println("********* " + response.getStatusCode());
StringWriter writer = new StringWriter();
IOUtils.copy(is, writer);
System.out.println(writer.toString());
I have also been able to create an entry (e.g. POST) only providing
InputStream: definitely nice.
I'll keep investigating for the Future<T> stuff...
Regards.
--
Francesco Chicchiriccò
ASF Member, Apache Syncope PMC chair, Apache Cocoon PMC Member
http://people.apache.org/~ilgrosso/