Chapter 47. XML-RPC

Table of Contents

1. <xmlrpc>
1.1. Attributes
1.2. Read-only properties
1.3. Methods
2. Using remotecall to creating function stubs

XML-RPC is simple spec that describes how to invoke a remote operation using XML over HTTP. OpenLaszlo XML-RPC is part of OpenLaszlo RPC and shares many of the same APIs and concepts. OpenLaszlo RPC includes SOAP and JavaRPC. For more information on XML-RPC, go to XML-RPC.com

1. <xmlrpc>

The <xmlrpc> element creates a client-side representation of an XML-RPC service. The service attribute is required and must be an URL.

Example 47.1. SOAP

<xmlrpc service="..."
      autoload="[true|false]"
      secure="[true|false]"
      secureport="..." >

1.1. Attributes

service: (String) URL of where service is located. This attribute is required.

autoload: (Boolean) if true, calls to load client proxy during init stage. If false, the proxy must be loaded using the load() method. See the proxy section in the RPC chapter for details. Default is true.

secure: (Boolean) if true, creates a secure HTTPS connection between the client and the OpenLaszlo Server. Also see secureport below. Default is false.

secureport: (Number) valid only when secure attribute is set to true. The secure port to use. There is no client-side default. Most servers use port 443 as the default HTTPS port.

1.2. Read-only properties

proxy: (Object) unlike other RPC services, proxy functions are created based on declared remotecall elements. Because there is no XML-RPC service description, each function stub in the proxy is created by remotecall elements declared by the developer. In other RPC services, declared remotecalls refer to proxy function stubs that exist after load.

1.3. Methods

1.3.1. load()

Load() is responsible for setting up the proxy property. The proxy will have function stubs based on remotecalls declared in the body of the <xmlrpc> element. This method is automatically invoked if autoload is true. When the call returns, an onload event is sent.

1.3.2. unload()

This method unloads the proxy from the RPC object and sets it to null. When the call returns, an onunload event is sent.

2. Using remotecall to creating function stubs

Most OpenLaszlo RPC objects like JavaRPC and SOAP will set function stubs in the proxy property during load based on methods described by a class (for JavaRPC) or on a service description (using a WSDL in SOAP). Remotecall declarations refer to these function stubs and any remotecalls not pointing to a function stub that doesn't exist will generate an error or warning. In <xmlrpc>, function stubs are create based on remotecall declarations. Note that XML-RPC use dot notation for their operation names. Because that will conflict with the view system's notation, it's suggested that remotecalls be explictly named.

Example 47.2. Creating a function stub


<canvas debug="true" height="400">
    <!-- this isues one call of the freshmeat XML-RPC API -->
    <!-- Documented here: http://freshmeat.net/faq/view/49/ -->

    <debug x="10" y="40" width="450" height="350" />

    <xmlrpc name="freshmeat"
            service="http://freshmeat.net/xmlrpc/">

        <handler name="onload">
            Debug.write('freshmeat XML-RPC service loaded');
            Debug.write('proxy:');
            Debug.inspect(this.proxy);
        </handler>

        <handler name="ondata" args="data">
            Debug.write('got data:', data);
        </handler>

        <handler name="onerror" args="error">
            Debug.write('onerror:', error);
        </handler>

        <remotecall name="fal" funcname="fetch_available_licenses" />

    </xmlrpc>

    <button text="fetch_available_licenses" x="10" y="10">
        <handler name="onclick">
            Debug.write('getting licenses...');
            freshmeat.fal.invoke()
        </handler>
    </button>

</canvas>