Andreas Franke - Jürgen Zimmer
This is a simple XML-RPC server and client implementation. It aims to conform with the spec at http://www.xmlrpc.com/spec with a few limitations (e.g. <dateTime.iso8601> is not supported yet, because we don't need it).
An XmlRpcHandler class must inherit from
XmlRpcHandler('class') at 'x-ozlib://mathweb/xmlrpc/XmlRpcHandler.ozf'It must implement the following method:
meth execute(MethodNameVS Params ?Result) ... endExceptions that occur while processing this method are automatically converted to XML-RPC <fault>s. Exceptions of the form
fault(FaultCode FaultString)are mapped naturally; other exceptions are converted to faults with FaultCode=0.
This package can be installed by following the usual
configure, build, install procedure, i.e. by executing a the
shell:
./configure
make install
By default, all files of the package are
installed in the user's ~/.oz directory tree. In
particular, all modules are installed in the user's private cache.
functor % A generic command line XML-RPC client
import
Application
System
Compiler
XmlRpcClient
at 'x-ozlib://mathweb/xmlrpc/XmlRpcClient.ozf'
define
AppName = "rpc"
Spec = record(host( single char:&h type:string default: "localhost")
port( single char:&p type:int default: 8080)
object(single type: bool default: true)
handler( single char:&H type:string default:"Broker")
methodName(single char:&M type:string default:"ping")
params( multiple char:&P type:list(string) default:nil)
)
Args
try
Args = {Application.getCmdArgs Spec}
catch error(ap(usage S)...) then
{System.showError AppName#": "#S}
{Application.exit 1}
end
Url = "http://"#Args.host#":"#Args.port#
if Args.object then "/RPC2" else "/RPC2/"#Args.handler end
{System.showInfo "url: "#Url}
MethodName =
if Args.object then Args.handler#"." else "" end # Args.methodName
{System.showInfo "methodName: "#MethodName}
Params = {Map Args.params Compiler.virtualStringToValue}
{System.showInfo "params: "}
{ForAll Params System.show}
{System.showInfo "\n"}
% calling the XML-RPC server
Result = {XmlRpcClient.execute Url MethodName Params}
{System.showInfo "result: "}
{System.show Result}
{Application.exit 0}
end