xml-rpc-procs.tcl

Initially created by Dave Bauer 2001-03-30 with inspiration from Steve Ball and help from Aaron Swartz and Jerry Asher.

Modified by Vinod Kurup to

  1. Use the xml abstraction procs in packages/acs-tcl/tcl/30-xml-utils-procs.tcl (which use tDom now)
  2. Fit in OpenACS 5 framework

Location:
packages/xml-rpc/tcl/xml-rpc-procs.tcl
Created:
2003-09-30
Author:
Vinod Kurup [vinod@kurup.com]
CVS Identification:
$Id: xml-rpc-procs.tcl,v 1.18 2022/08/26 18:26:27 gustafn Exp $

Procedures in this file

Detailed information

xmlrpc::construct (private)

 xmlrpc::construct context arglist

Construct an XML-RPC element. arglist is a 2-element list which is converted to XML. The first element of arglist is the datatype and the second element is the value.

Example:
    set arglist {-int 33}
    set result [xmlrpc::construct {} $arglist]
    set result ==> <i4>33</i4>
    

This proc works recursively, so if your top level list has a list within it, then that list will be processed first. The two examples of this are arrays and structs. In addition, structs and arrays can contain each other.

Array example:
    set arglist {-array {
        {-int 6682}
        {-boolean 0}
        {-text Iowa}
        {-double 8931.33333333}
        {-date {Fri Jan 01 05:41:30 EST 1904}}}}

    set result [xmlrpc::construct {} $arglist]
    set result ==>  <array>
                    <data>
                        <value>
                            <i4>6682</i4>
                        </value>
                        <value>
                            <boolean>0</boolean>
                        </value>
                        <value>
                            <string>Iowa</string>
                        </value>
                        <value>
                            <double>8931.33333333</double>
                        </value>
                        <value>
                            <dateTime.iso8601>19040101T05:41:30</dateTime.iso8601>
                        </value>
                    </data>
                </array>
    

struct's have the special format: -struct {name1 {-datatype1 value1} name2 {-datatype2 value2}}

Struct Example:
    set arglist {-struct {
        ctLeftAngleBrackets {-int 5}
        ctRightAngleBrackets {-int 6}
        ctAmpersands {-int 7}
        ctApostrophes {-int 0}
        ctQuotes {-int 3}}}

    set result [xmlrpc::construct {} $arglist]
    set result ==>  <struct>
                    <member>
                        <name>ctLeftAngleBrackets</name>
                        <value>
                            <i4>5</i4>
                        </value>
                    </member>
                    <member>
                        <name>ctRightAngleBrackets</name>
                        <value>
                            <i4>6</i4>
                        </value>
                    </member>
                    <member>
                        <name>ctAmpersands</name>
                        <value>
                            <i4>7</i4>
                        </value>
                    </member>
                    <member>
                        <name>ctApostrophes</name>
                        <value>
                            <i4>0</i4>
                        </value>
                    </member>
                    <member>
                        <name>ctQuotes</name>
                        <value>
                            <i4>3</i4>
                        </value>
                    </member>
                </struct>
    

The context parameter is used internally to create tags within tags.

Example:
    set arglist {-int 33}
    set result [xmlrpc::construct {foo bar} $arglist]
    set result ==> <foo><bar><i4>33</i4></bar></foo>
    

Parameters:
context - extra tags to wrap around the data
arglist - datatype-value list (or more complex types as described above)
Returns:
XML formatted result

Partial Call Graph (max 5 caller/called nodes):
%3 test_xml_rpc_construct xml_rpc_construct (test xml-rpc) xmlrpc::construct xmlrpc::construct test_xml_rpc_construct->xmlrpc::construct xmlrpc::create_context xmlrpc::create_context (private) xmlrpc::construct->xmlrpc::create_context xmlrpc::remote_call xmlrpc::remote_call (public) xmlrpc::remote_call->xmlrpc::construct xmlrpc::respond xmlrpc::respond (private) xmlrpc::respond->xmlrpc::construct

Testcases:
xml_rpc_construct

xmlrpc::create_context (private)

 xmlrpc::create_context context value

Return the value wrapped in appropriate context tags. If context is a list of items, then the result will be wrapped in multiple tags. Example:

    xmlrpc::create_context {param value} 78
    returns ==> "<param><value>78</value></param>"
    

Parameters:
context - context to create
value - character data
Returns:
string with value wrapped in context tags

Partial Call Graph (max 5 caller/called nodes):
%3 xmlrpc::construct xmlrpc::construct (private) xmlrpc::create_context xmlrpc::create_context xmlrpc::construct->xmlrpc::create_context

Testcases:
No testcase defined.

xmlrpc::decode_value (private)

 xmlrpc::decode_value node

Unpack the data in a value element. Most value elements will have a subnode describing the datatype (e.g. <string> or <int>). If no subnode is present, then we should assume the value is a string.

Parameters:
node - <value> node that we're decoding
Returns:
Returns the contents of the <value> node. If the value is a <struct> then returns the data in a TCL array. If the value is an <array> then returns the data in a TCL list.

Partial Call Graph (max 5 caller/called nodes):
%3 test_xml_rpc_decode_value xml_rpc_decode_value (test xml-rpc) xmlrpc::decode_value xmlrpc::decode_value test_xml_rpc_decode_value->xmlrpc::decode_value test_xml_rpc_fault xml_rpc_fault (test xml-rpc) test_xml_rpc_fault->xmlrpc::decode_value test_xml_rpc_respond xml_rpc_respond (test xml-rpc) test_xml_rpc_respond->xmlrpc::decode_value xml_node_get_children xml_node_get_children (public) xmlrpc::decode_value->xml_node_get_children xml_node_get_children_by_name xml_node_get_children_by_name (public) xmlrpc::decode_value->xml_node_get_children_by_name xml_node_get_content xml_node_get_content (public) xmlrpc::decode_value->xml_node_get_content xml_node_get_first_child xml_node_get_first_child (public) xmlrpc::decode_value->xml_node_get_first_child xml_node_get_name xml_node_get_name (public) xmlrpc::decode_value->xml_node_get_name xmlrpc::invoke xmlrpc::invoke (private) xmlrpc::invoke->xmlrpc::decode_value xmlrpc::parse_response xmlrpc::parse_response (private) xmlrpc::parse_response->xmlrpc::decode_value xmlrpc::test::decode_test_prep xmlrpc::test::decode_test_prep (private) xmlrpc::test::decode_test_prep->xmlrpc::decode_value

Testcases:
xml_rpc_fault, xml_rpc_decode_value, xml_rpc_respond

xmlrpc::enabled_p (public)

 xmlrpc::enabled_p
Returns:
whether the server is enabled

Partial Call Graph (max 5 caller/called nodes):
%3 packages/xml-rpc/www/admin/index.tcl packages/xml-rpc/ www/admin/index.tcl xmlrpc::enabled_p xmlrpc::enabled_p packages/xml-rpc/www/admin/index.tcl->xmlrpc::enabled_p packages/xml-rpc/www/admin/toggle.tcl packages/xml-rpc/ www/admin/toggle.tcl packages/xml-rpc/www/admin/toggle.tcl->xmlrpc::enabled_p xmlrpc::invoke xmlrpc::invoke (private) xmlrpc::invoke->xmlrpc::enabled_p parameter::get_from_package_key parameter::get_from_package_key (public) xmlrpc::enabled_p->parameter::get_from_package_key

Testcases:
No testcase defined.

xmlrpc::fault (private)

 xmlrpc::fault code msg

Format a fault response to a XML-RPC request

Parameters:
code - error code (integer)
msg - error message
Returns:
XML-RPC fault message

Partial Call Graph (max 5 caller/called nodes):
%3 test_xml_rpc_fault xml_rpc_fault (test xml-rpc) xmlrpc::fault xmlrpc::fault test_xml_rpc_fault->xmlrpc::fault xml_doc_free xml_doc_free (public) xmlrpc::fault->xml_doc_free xml_doc_render xml_doc_render (public) xmlrpc::fault->xml_doc_render xml_parse xml_parse (public) xmlrpc::fault->xml_parse xmlrpc::invoke xmlrpc::invoke (private) xmlrpc::invoke->xmlrpc::fault xmlrpc::parse_response xmlrpc::parse_response (private) xmlrpc::parse_response->xmlrpc::fault

Testcases:
xml_rpc_fault

xmlrpc::get_content (private)

 xmlrpc::get_content

There's no [ns_conn content] so this is a hack to get the content of the XML-RPC request. Taken from ns_xmlrpc.

Returns:
string - the XML request
Author:
Dave Bauer

Partial Call Graph (max 5 caller/called nodes):
%3 packages/xml-rpc/www/index.tcl packages/xml-rpc/ www/index.tcl xmlrpc::get_content xmlrpc::get_content packages/xml-rpc/www/index.tcl->xmlrpc::get_content ad_tmpnam ad_tmpnam (public) xmlrpc::get_content->ad_tmpnam

Testcases:
No testcase defined.

xmlrpc::httppost (private)

 xmlrpc::httppost [ -url url ] [ -timeout timeout ] [ -depth depth ] \
    [ -content content ]

The proc util_httppost doesn't work for our needs. We need to send Content-type of text/xml and we need to send a Host header. So, roll our own XML-RPC HTTP POST. Wait - lars-blogger sends out XML-RPC pings to weblogs.com. I'll steal the POST code from there and simplify that call.

Switches:
-url
(optional)
-timeout
(defaults to "30") (optional)
-depth
(defaults to "0") (optional)
-content
(optional)
Author:
Vinod Kurup

Partial Call Graph (max 5 caller/called nodes):
%3 xmlrpc::remote_call xmlrpc::remote_call (public) xmlrpc::httppost xmlrpc::httppost xmlrpc::remote_call->xmlrpc::httppost util::http::post util::http::post (public) xmlrpc::httppost->util::http::post

Testcases:
No testcase defined.

xmlrpc::invoke (private)

 xmlrpc::invoke xml

Take the XML-RPC request and invoke the method on the server. The methodName element contains the Tcl procedure to evaluate. The method is called from the global stack level.

Parameters:
xml - XML-RPC data from the client
Returns:
result encoded in XML and ready for return to the client

Partial Call Graph (max 5 caller/called nodes):
%3 packages/xml-rpc/www/index.tcl packages/xml-rpc/ www/index.tcl xmlrpc::invoke xmlrpc::invoke packages/xml-rpc/www/index.tcl->xmlrpc::invoke xml_doc_free xml_doc_free (public) xmlrpc::invoke->xml_doc_free xml_doc_get_first_node xml_doc_get_first_node (public) xmlrpc::invoke->xml_doc_get_first_node xml_node_get_children_by_name xml_node_get_children_by_name (public) xmlrpc::invoke->xml_node_get_children_by_name xml_node_get_content xml_node_get_content (public) xmlrpc::invoke->xml_node_get_content xml_node_get_first_child xml_node_get_first_child (public) xmlrpc::invoke->xml_node_get_first_child

Testcases:
No testcase defined.

xmlrpc::invoke_method (private)

 xmlrpc::invoke_method method_name arguments

Call the given method on the OpenACS server. It's up to the caller to catch any error that we get.

Parameters:
method_name - methodName from XML-RPC
arguments - list of arguments
Returns:
result of the OpenACS proc
Author:
Vinod Kurup

Partial Call Graph (max 5 caller/called nodes):
%3 system.multicall system.multicall (public) xmlrpc::invoke_method xmlrpc::invoke_method system.multicall->xmlrpc::invoke_method xmlrpc::invoke xmlrpc::invoke (private) xmlrpc::invoke->xmlrpc::invoke_method

Testcases:
No testcase defined.

xmlrpc::list_methods (public)

 xmlrpc::list_methods
Returns:
alphabetical list of XML-RPC procs on this server

Partial Call Graph (max 5 caller/called nodes):
%3 packages/xml-rpc/www/admin/index.tcl packages/xml-rpc/ www/admin/index.tcl xmlrpc::list_methods xmlrpc::list_methods packages/xml-rpc/www/admin/index.tcl->xmlrpc::list_methods system.listMethods system.listMethods (public) system.listMethods->xmlrpc::list_methods

Testcases:
No testcase defined.

xmlrpc::parse_response (private)

 xmlrpc::parse_response xml

Parse the response from a XML-RPC call.

Parameters:
xml - the XML response
Returns:
result

Partial Call Graph (max 5 caller/called nodes):
%3 xmlrpc::remote_call xmlrpc::remote_call (public) xmlrpc::parse_response xmlrpc::parse_response xmlrpc::remote_call->xmlrpc::parse_response xml_doc_free xml_doc_free (public) xmlrpc::parse_response->xml_doc_free xml_doc_get_first_node xml_doc_get_first_node (public) xmlrpc::parse_response->xml_doc_get_first_node xml_node_get_first_child xml_node_get_first_child (public) xmlrpc::parse_response->xml_node_get_first_child xml_node_get_name xml_node_get_name (public) xmlrpc::parse_response->xml_node_get_name xml_parse xml_parse (public) xmlrpc::parse_response->xml_parse

Testcases:
No testcase defined.

xmlrpc::register_proc (public)

 xmlrpc::register_proc proc_name

Register a proc to be available via XML-RPC. proc_name is the name of a proc that is defined in the usual OpenACS way (i.e. ad_proc). The proc_name is added to the xmlrpc_procs nsv array with a value of 1. When an XML-RPC call comes in, this array is searched to see if the proc_name has been registered. Currently, the presence of proc_name in the nsv is enough to indicate that the proc can be called via XML-RPC. At some point we may allow administrators to disable procs, so we could set the value associated with proc_name from 1 to 0.

Parameters:
proc_name - Name of proc to be registered.
Returns:
nothing

Partial Call Graph (max 5 caller/called nodes):
%3 packages/xml-rpc/tcl/system-init.tcl packages/xml-rpc/ tcl/system-init.tcl xmlrpc::register_proc xmlrpc::register_proc packages/xml-rpc/tcl/system-init.tcl->xmlrpc::register_proc packages/xml-rpc/tcl/validator-init.tcl packages/xml-rpc/ tcl/validator-init.tcl packages/xml-rpc/tcl/validator-init.tcl->xmlrpc::register_proc

Testcases:
No testcase defined.

xmlrpc::remote_call (public)

 xmlrpc::remote_call url method [ args ]

Invoke a method on a remote server using XML-RPC

Parameters:
url - url of service
method - method to call
args (optional) - list of args to the method
Returns:
the response of the remote service. Error if remote service returns a fault.

Partial Call Graph (max 5 caller/called nodes):
%3 xml_doc_free xml_doc_free (public) xml_doc_render xml_doc_render (public) xml_parse xml_parse (public) xmlrpc::construct xmlrpc::construct (private) xmlrpc::httppost xmlrpc::httppost (private) xmlrpc::remote_call xmlrpc::remote_call xmlrpc::remote_call->xml_doc_free xmlrpc::remote_call->xml_doc_render xmlrpc::remote_call->xml_parse xmlrpc::remote_call->xmlrpc::construct xmlrpc::remote_call->xmlrpc::httppost

Testcases:
No testcase defined.

xmlrpc::respond (private)

 xmlrpc::respond data

Format a success response to an XML-RPC request

Parameters:
data - data to be returned to the client
Returns:
data encoded in a properly formed XML-RPC response

Partial Call Graph (max 5 caller/called nodes):
%3 test_xml_rpc_respond xml_rpc_respond (test xml-rpc) xmlrpc::respond xmlrpc::respond test_xml_rpc_respond->xmlrpc::respond xml_doc_free xml_doc_free (public) xmlrpc::respond->xml_doc_free xml_doc_render xml_doc_render (public) xmlrpc::respond->xml_doc_render xml_parse xml_parse (public) xmlrpc::respond->xml_parse xmlrpc::construct xmlrpc::construct (private) xmlrpc::respond->xmlrpc::construct xmlrpc::invoke xmlrpc::invoke (private) xmlrpc::invoke->xmlrpc::respond

Testcases:
xml_rpc_respond

xmlrpc::url (public)

 xmlrpc::url
Returns:
the URL that is listening for RPC requests
Author:
Vinod Kurup

Partial Call Graph (max 5 caller/called nodes):
%3 test_xml_rpc_validate xml_rpc_validate (test xml-rpc) xmlrpc::url xmlrpc::url test_xml_rpc_validate->xmlrpc::url apm_package_url_from_key apm_package_url_from_key (public) xmlrpc::url->apm_package_url_from_key packages/xml-rpc/www/admin/index.tcl packages/xml-rpc/ www/admin/index.tcl packages/xml-rpc/www/admin/index.tcl->xmlrpc::url

Testcases:
xml_rpc_validate
[ show source ]