Marvin supports versions 1.0 and 1.1. of the JSON Schema Service Descriptor. The available operations and parameters of the service are discovered during the run-time.

    As the JSON calls are based on the HTTP protocol, the calls can be POST or GET methods. Both are supported by Marvin. Answers of the JSON RPC call must be JSON text answers, or the RPC will not work.

    The response MUST be a textual representation of any finite combinations of java.lang.Boolean, java.lang.Number, java.lang.String, java.lang.Object[], java.util.Map<java.lang.String, java.lang.Object> , and null.

    Results are handled similarly as described at WSDL/SOAP RPC services.

    Calling JSON-RPC Service from API

    This is an example of how to handle JSON services through the API.

        JsonServiceDescriptor descriptor = new JsonServiceDescriptor();
        descriptor.addArgument(ServiceArgument.createArgument("north", new Double(0)));
        descriptor.addArgument(ServiceArgument.createArgument("south", new Double(0)));
        descriptor.addArgument(ServiceArgument.createArgument("east", new Double(0)));
        descriptor.addArgument(ServiceArgument.createArgument("west", new Double(0)));
        descriptor.addArgument(ServiceArgument.createArgument("language", ""));
        descriptor.addArgument(ServiceArgument.createArgument("username", ""));
        Object result = null;
        try {
            result = descriptor.getServiceHandler().callService(descriptor, 44.1, -9.9, 22.4, 55.2, "en", "demo");
        } catch (ServiceException e) {
            System.err.println("Service call failed.");
        StringBuilder builder = new StringBuilder();
        Object[] array = (Object[]) ((Map<String, Object>)result).get("geonames");
        for(Object obj : array) {
            builder.append("Synchronized call returned: " + ((Map<String, Object>)obj).get("name") + "\n");
        descriptor.getServiceHandler().callService(descriptor, new AsyncCallback<Map<String, Object>>() {
            public void onSuccess(Map<String, Object> result) {
                StringBuilder builder = new StringBuilder();
                Object[] array = (Object[]) result.get("geonames");
                for(Object obj : array) {
                    builder.append("Asynchronous call returned: " + ((Map<String, Object>)obj).get("name") + "\n");
            public void onFailure(ServiceException caught) {
                System.err.println("Asynchronous call failed.");
        }, 44.1, -9.9, 22.4, 55.2, "en", "demo");