Skip to content

HTTP

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.

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

HTTP service options

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

Example HTTP service

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);