Dashboard > Pulse v2.1 > ... > Remote API Examples > Java Example - Ping
  Pulse v2.1 Log In | Sign Up   View a printable version of the current page.  
  Java Example - Ping
Added by Jason Sankey, last edited by Jason Sankey on Mar 19, 2009
Labels: 
(None)

Pulse Manual Index

Overview

This example is the most basic connectivity test between client code and the pulse™ XML-RPC service.

Code

import org.apache.xmlrpc.client.XmlRpcClient;
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
import org.apache.xmlrpc.XmlRpcException;

import java.net.URL;
import java.net.MalformedURLException;
import java.util.Collections;

/**
 * The most trivial example, which demonstrates the ability to contact the remote
 * API.
 */
public class Ping
{
    private static final String PULSE_URL = "http://pulse/xmlrpc";

    public static void main(String[] argv) throws MalformedURLException, XmlRpcException
    {
        // Create a client to talk to the Pulse XML-RPC service.
        XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
        config.setServerURL(new URL(PULSE_URL));
        XmlRpcClient client = new XmlRpcClient();
        client.setConfig(config);

        // Simple method invocation, good for testing connectivity.
        String response = (String) client.execute("RemoteApi.ping", Collections.emptyList());
        System.out.println("Response: " + response);
    }
}

Zutubi wiki is Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.2.10 Build:#528 Nov 29, 2006) - Bug/feature request - Contact Administrators