Table of Contents
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
The <xmlrpc> element creates a client-side representation of an XML-RPC service. The service attribute is required and must be an URL.
Example 48.1. SOAP
<xmlrpc service="..." autoload="[true|false]" secure="[true|false]" secureport="..." >
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.
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.
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.
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 explicitly named.
Example 48.2. Creating a function stub
<canvas
debug
="true
" height
="400
" width
="100%
">
<!-- this isues one call of the freshmeat XML-RPC API -->
<!-- Documented here: http://freshmeat.net/faq/view/49/ -->
<xmlrpc
name
="freshmeat
" service
="http://freshmeat.net/xmlrpc/
">
<handler
name
="onload
">
Debug.debug('freshmeat XML-RPC service loaded');
Debug.debug('proxy:');
Debug.inspect(this.proxy);
</handler
>
<handler
name
="ondata
" args
="data
">
Debug.debug('got data: %w', data);
</handler
>
<handler
name
="onerror
" args
="error
">
Debug.debug('onerror: %w', error);
</handler
>
<remotecall
name
="fal
" funcname
="fetch_available_licenses
"/>
</xmlrpc
>
<button
text
="fetch_available_licenses
" x
="10
" y
="10
">
<handler
name
="onclick
">
Debug.debug('getting licenses...');
freshmeat.fal.invoke()
</handler
>
</button
>
</canvas
>
<!-- * X_LZ_COPYRIGHT_BEGIN ***************************************************
* Copyright 2007, 2008 Laszlo Systems, Inc. All Rights Reserved. *
* Use is subject to license terms. *
* X_LZ_COPYRIGHT_END ****************************************************** -->
Copyright © 2002-2010 Laszlo Systems, Inc. All Rights Reserved. Unauthorized use, duplication or distribution is strictly prohibited. This is the proprietary information of Laszlo Systems, Inc. Use is subject to license terms.