Contract| No input parameters. | | Water Contract<class xmlrpc
/> | |
Water XML-RPC fully integrates Water with XML-RPC.
The first example defines a Water method quote , defines and configures
an HTTP Water server, defines a local XML-RPC proxy named remote_quote
to the quote method on that server, and then calls the remote service via XML-RPC
using that proxy, passing in an argument value of 10, which returns
the integer 11.
<method wob.quote amount=req> amount.<plus 1/> </>
<server root=wob port=8080/>
<set remote_quote = resource.<xmlrpc "http://localhost:8080" contract=quote/> />
<remote_quote amount=10/>
 | 11 |
The example above is worth taking some time to understand. The
equivalent setup and functionality might take more than 10 pages
using other technologies.
The first example shows several ways in which Water integrates
with XML-RPC. Here is a complete list of Water XML-RPC functionality:
Directly execute any XML-RPC string to return a Water objectConvert any Water object into an XML-RPC stringWater calling an XML-RPC serverXML-RPC client calling a Water serverGet value from Water server encoded in XML-RPC
Examples for each of these uses of Water XML-RPC are
shown below.
Example: Executing XML-RPC to return a Water object
<methodResponse>
<params>
<param>
<value>
<array>
<data>
<value><double>4.12</double></value>
<value><string>Water XML-RPC</string></value>
</data>
</array>
</value>
</param>
</params>
</methodResponse> | <vector 4.12 "Water XML-RPC"/>
|
Converting Water object into XML-RPC using to_xmlrpc .
<vector 4.12 "Water XML-RPC"/>.<to_xmlrpc/>
 | "<array>
<data>
<value><double>4.12</double></value>
<value><string>Water XML-RPC</string></value>
</data>
</array>" |
A value can be wrapped in an XML-RPC methodReponse using to_xmlrpc_response .
<vector 4.12 "Water XML-RPC"/>.<to_xmlrpc_response/>
 | "<methodResponse>
<params>
<param>
<value><array>
<data>
<value><double>4.12</double></value>
<value><string>Water XML-RPC</string></value>
</data>
</array></value>
</param>
</params>
</methodResponse>" |
Every Water server automatically supports both XML-RPC
requests and return values.
You can use a standard browser to make a request using
a URI/URL. The path's extension indicates that the return
value should be encoded in XML-RPC.
<method quote symbol=req=string>
symbol
</method>
<server root=wob port=8080/>
<open_browser_window "http://localhost:8080/quote.xmlrpc?symbol=IBM"/>
Alternatively, you can use an XML-RPC client to send the following
XML-RPC message to http://localhost:8080 <methodCall>
<methodName>quote</methodName>
<params>
<param><value><string>CM</string></value></param>
</params>
</methodCall>
 | xmlrpc.<methodCall args=<v "CM"/> method_name="quote"/> |
If the Water server receives a request in XML-RPC, it defaults to
sending the response encoded in XML-RPC. The result can be shown
in any format by using the URI's file extension. The URI's file
extension determines how the result will be formatted.
An XML-RPC message can be used to also call a local Water
method by calling request on a methodCall . The
return result is a Water object.
<method quote arg=req> arg </>
<methodCall>
<methodName>quote</methodName>
<params>
<param><value><string>CM</string></value></param>
</params>
</methodCall>.<request/>
 | "CM" |
The methodCall expression above is the same as:
<quote "CM"/>
"CM"
Although XML-RPC only allows resources to be called using the methodCall
tag, Water also supports getting a static value in XML-RPC encoding.
Example: Getting the value of a remote resource in XML-RPC encoding
thing.<set xxx=<vector 3 10/> />
<server root=thing port=8080/>
<resource "http://localhost:8080/xxx.xmlrpc"/>.content
 | '<?xml version="1.0"?>
<methodResponse>
<params>
<param>
<value><array>
<data>
<value><int>3</int></value>
<value><int>10</int></value>
</data>
</array></value>
</param>
</params>
</methodResponse>' |
© Copyright 2007 Clear Methods, Inc.