[OTDev] Java Clients - Any suggestions?

chung chvng at mail.ntua.gr
Fri Oct 2 14:04:07 CEST 2009


Hi Nina,

On Thu, 2009-10-01 at 20:44 +0300, Nina Jeliazkova wrote:
> Hi Pantelis,
> 
> You could simply use java.net.HttpURLConnection :
> 
>             HttpURLConnection conn = (HttpURLConnection)
>     url.openConnection();
>             conn.setRequestMethod("GET");
>             conn.setUseCaches(false);
>             conn.setRequestProperty("Accept","chemical/x-daylight-smiles");

Thanks for the code! Seems more convenient than org.apache.HttpClient! 
Is there an easy way of retrieving ids out of a given URI? e.g. given
"http://ambit.uni-plovdiv.bg:8080/ambit2/dataset/8/compound/432" I want
to get the dataset id "8". I tried out the following using restlet:

Reference ref = new
Reference("http://ambit.uni-plovdiv.bg:8080/ambit2/dataset/8");
String datasetId =  ref.getSegments().get(2) ; 
String compoundId =  ref.getSegments().get(4) 

Is there a better way of doing this with restlet? How could I specify
header information in restlet? 

Best Regards,
Pantelis

> 
> 
> Here is the code from our demo client earlier this year:  
> https://ambit.svn.sourceforge.net/svnroot/ambit/branches/ambit-rest-client/src/main/java/ambit2/client/rest/Query.java
> 
> 
> For more complex applications, Restlet is much more convenient.   Sun's
> Jersey is another Java REST library https://*jersey*.dev.java.net . 
> Have no experience wit Apache HttpClient.
> 
> Best regards,
> Nina
> 
> chung wrote:
> > Dear All,
> >  Does anyone have some experience with clients written in Java. I want
> > to perform a GET request specifying the header "Accept:text/xml". Can I
> > do that using the HttpClient class
> > ( http://hc.apache.org/httpclient-3.x/ ) or maybe restlet? Which Java
> > library do you think would be a good choice? 
> >
> > Thank you in advance,
> > Pantelis
> >
> > _______________________________________________
> > Development mailing list
> > Development at opentox.org
> > http://www.opentox.org/mailman/listinfo/development
> >   
> 
> _______________________________________________
> Development mailing list
> Development at opentox.org
> http://www.opentox.org/mailman/listinfo/development




More information about the Development mailing list