The <rpc>
tag is the abstract base class for RPC classes. Subclasses
must implement the load()
method, which is responsible for creating
the proxy object. The proxy object contains a set of function stubs
that invoke a remote function (or procedure) over the network. It's
up to the caller of the stub function to know what parameters need to
be passed in by looking at what the backend remote function expects.
If calling a JavaRemoting (<javarpc>
) function, looking at the associated
Java API will be necessary. If calling a SOAP (<soap>
) function, the
developer will need to look at the corresponding operation in a WSDL file.
The implementation of this class can be found in lps/components/rpc/rpc.lzx. For details, see the RPC chapter of the Developer's Guide.
Objects derived from rpc use function stubs in the proxy object to invoke a remote function. Each function stub expects an array of arguments and a delegate to deal with the return value, respectively. Both the array and the delegate are required. If a function has no arguments, rpc passes in an empty array.
Example 81. Invoking remote function using proxy function stub
<canvas
debug
="true
" height
="280
">
<debug
x
="10
" y
="40
" width
="470
" height
="230
"/>
<soap
name
="temperature
" autoload
="false
" wsdl
="http://developerdays.com/cgi-bin/tempconverter.exe/wsdl/ITempConverter
">
<method
name
="init
">
super.init();
Debug.debug('soap service loading...');
this.load();
</method
>
<handler
name
="onload
">
Debug.debug('temperature service loaded!');
Debug.debug('---');
// don't allow others to call RPC object until proxy is loaded.
canvas.convert.setAttribute('visible', true);
</handler
>
</soap
>
<button
name
="convert
" text
="convert
" x
="10
" y
="10
" visible
="false
">
<attribute
name
="myDel
" value
="$once{new LzDelegate(this, 'myhandler')}
"/>
<handler
name
="onclick
">
var f = 100;
canvas.temperature.proxy.FtoC([ f ], this.myDel)
Debug.debug('Invoking FtoC...');
</handler
>
<method
name
="myhandler
" args
="data
">
Debug.debug('got data: %w', data);
</method
>
</button
>
</canvas
>
Alternatively, you can use remotecall for a more declarative approach to invoking functions.
See the <remotecall>
reference or the RPC chapter of the Developer's Guide for more information.
Example 82. Invoking remote function using remotecall
<canvas
debug
="true
" height
="280
">
<debug
x
="10
" y
="40
" width
="470
" height
="230
"/>
<soap
name
="temperature
" autoload
="false
" wsdl
="http://developerdays.com/cgi-bin/tempconverter.exe/wsdl/ITempConverter
">
<method
name
="init
">
super.init();
Debug.debug('soap service loading...');
this.load();
</method
>
<handler
name
="onload
">
Debug.debug('temperature service loaded!');
Debug.debug('---');
// don't allow others to call RPC object until proxy is loaded.
canvas.convert.setAttribute('visible', true);
</handler
>
<remotecall
funcname
="FtoC
">
<param
value
="100
"/>
<handler
name
="ondata
" args
="value
">
Debug.debug('got data: %w', value);
</handler
>
<handler
name
="onerror
" args
="errmsg
">
Debug.debug('error: %w', errmsg);
</handler
>
</remotecall
>
</soap
>
<button
name
="convert
" text
="convert
" x
="10
" y
="10
" visible
="false
">
<handler
name
="onclick
">
canvas.temperature.FtoC.invoke();
Debug.debug('Invoking FtoC...');
</handler
>
</button
>
</canvas
>
See Also:
Name (CSS property) | Type (tag) | Type (js) | Default | Category |
---|---|---|---|---|
autoload
|
boolean | boolean | true | read/write |
Load remote object during init. If false, create remote object by calling load(). Default is true. | ||||
proxy
|
expression | any | null | readonly |
The remote proxy object. Proxy is set after the rpc object loads. Proxy contains client-side function stubs to remote methods. Each method takes an array of arguments and a delegate like: myrpc.proxy.remoteFunc( [ p1, p2, ..., pN ], delegate ); Remote methods with no arguments are passed in an empty array like: myrpc.proxy.otherRemoteFunc( [], delegate ); The delegate is used to handle the return value since RPC calls are asynchronous. | ||||
proxyinfo
|
expression | any | null | read/write |
secure
|
boolean | boolean | false | read/write |
Make connection secure between client and the LPS secure (HTTPS). Default is false. | ||||
secureport
|
number | Number | null | read/write |
The port to use for the secure socket between the client and the LPS. If secure is false, this value is ignored. |
classroot, cloneManager, data, datapath, defaultplacement, id, ignoreplacement, immediateparent, inited, initstage, name, nodeLevel, options, parent, placement, styleclass, subnodes, transition
Methods
animate, applyConstraintMethod, applyData, childOf, completeInstantiation, construct, createChildren, dataBindAttribute, destroy, determinePlacement, getOption, getUID, init, lookupSourceLocator, releaseConstraint, releaseConstraintMethod, searchImmediateSubnodes, searchSubnodes, setOption, setSelected, updateData
Events
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.