HTTP

Introduction

HTTP Service is the most lightweight and unrestricted remote service: it supports POST and GET requests to a predefined URL. The result is retrieved as is and rendered as a webpage.

Examples

Example 1

This example shows how to call chemicalize.com through an HTTP web service. In this case, the pKa values of a molecule are calculated.

images/download/attachments/1802795/image2015-12-7_15_48_9.png

An example calculation with this web service can be found below.

images/download/attachments/1802795/image2015-12-7_15_51_41.png

Example 2

This example shows how to reach the functionalities of chemicalize.com through HTTP API.

HTTPServiceDescriptor descriptor = new HTTPServiceDescriptor();
descriptor.setURL("https://chemicalize.com/tomcat-files/datapage.jsp");
descriptor.addArgument(ServiceArgument.createArgument("mol", ""));
descriptor.addArgument(ServiceArgument.createArgument("special", ""));
descriptor.addArgument(ServiceArgument.createArgument("pka_width", 0));
 
Object result = null;
try {
result = descriptor.getServiceHandler().callService(descriptor, "c1ccnccc1", "pka", 300);
} catch (ServiceException e) {
System.err.println("Service call failed.");
}
System.out.println("Synchronized call returned: " + String.valueOf(result));
 
descriptor.getServiceHandler().callService(descriptor, new AsyncCallback<String>() {
 
@Override
public void onSuccess(String result) {
System.out.println("Aynchronous call returned: " + result);
}
 
@Override
public void onFailure(ServiceException caught) {
System.err.println("Asynchronous call failed.");
}
}, "c1ccnccc1", "pka", 300);