Forum OpenACS Q&A: ns_xmlrpc fails validator.xmlrpc.com

Collapse
Posted by Andrew Piskorski on
I just installed nsxml, ns_xmlrpc, and ran it through Userland's XML-RPC Validator. All the tests passed except the manyTypesTest.

Now, that test failed due to "Error: Poorly formed XML text, string constant is improperly formatted. (At character #213.)", because AOLserver didn't send back XML, the ns_xmlrpc code died and AOLserver sent back it's usual Server Error HTML message. The stack trace was:

[02/Jul/2002:20:02:24][17809.8][-conn0-] Error: value "Fri Jan 01 09:23:58 EWT 1904" 
for option "-date" is not a valid date 
(unable to convert date-time string "Fri Jan 01 09:23:58 EWT 1904")
value "Fri Jan 01 09:23:58 EWT 1904" for option "-date" is not a valid date 
(unable to convert date-time string "Fri Jan 01 09:23:58 EWT 1904")
    while executing
"xmlrpc_construct $data value $datum"
    ("foreach" body line 2)
    invoked from within
"foreach datum $value {
                set result [xmlrpc_construct $data value $datum]
                if {[llength $result]} {
                    r..."
    ("-array" arm line 4)
    invoked from within
"switch -- $option {
            -string -
            -text {
                ns_xml node setcontent  [xmlrpc_createContext $node $context]  $value
  ..."
    (procedure "xmlrpc_construct" line 18)
    invoked from within
"xmlrpc_construct $value_id {} $data"
    (procedure "xmlrpc_respond" line 8)
    invoked from within
"xmlrpc_respond $result"
    (procedure "xmlrpc_invoke" line 33)
    invoked from within
"xmlrpc_invoke $content"
    (procedure "xml_rpcdispatcher" line 12)
    invoked from within
"xml_rpcdispatcher"

The dateTime part of the request validator.xmlrpc.com is sending my server is this:

<value><dateTime.iso8601>19040101T08:23:58</dateTime.iso8601></value>

The validator1.manyTypesTest proc is taking its incoming dateTime variable and doing this to it:

[list -date [clock format $dateTime]]

And the Tcl error is coming from this code in xmlrpc_construct:

-date {
    if {[catch {
        clock format [clock scan $value] 
              -format {%Y%m%dT%H:%M:%S}
    } datevalue]} {
        return -code error 
                "value "$value" for option "$option" is not a valid date ($datevalue)"
    }
    ns_xml node new_child 
            [xmlrpc_createContext $node $context] 
            "dateTime.iso8601" $datevalue
}

So, I'm not sure what's going on there, but it looks to me like the clock command proc validator1.manyTypesTest is probably messed up.

Is the intention there to convert the incoming dateTime.iso8601 format into Tcl's internal integer representation? I don't think so, because then it'd be doing a clock scan, not clock format. And anyway, I tried the obvious fixes of changing it to either [list -date $dateTime] or [list -date [clock scan $dateTime]], and neither of those worked, they just changed the nature of the error.

So, what are these different bits of code supposed to be doing? Could someone knowledgeable please explain how these bits of ns_xmlrpc are supposed to work? I suspect it's simple but I don't see it...