<commit_before># Client implementation of the SOAP Interoperability lab Round 1 Test Suite.

package require SOAP
package require XMLRPC
package require rpcvar

namespace eval soapinterop {
    variable uri    "http://soapinterop.org/"
    variable action "urn:soapinterop"

    rpcvar::typedef -namespace http://soapinterop.org/xsd { \
	    varString string \
	    varInt    int \
	    varFloat  float} SOAPStruct

    proc create {proxy} {
        variable uri
        variable action
        
        SOAP::create echoString  -proxy $proxy -uri $uri -action $action \
                -params {inputString string}
        SOAP::create echoInteger -proxy $proxy -uri $uri -action $action \
                -params {inputInteger int}
        SOAP::create echoFloat -proxy $proxy -uri $uri -action $action \
                -params {inputFloat float}
        SOAP::create echoStruct -proxy $proxy -uri $uri -action $action \
                -params {inputStruct SOAPStruct}
        
        SOAP::create echoStringArray -proxy $proxy -uri $uri -action $action \
                -params {inputStringArray string()}
        SOAP::create echoIntegerArray -proxy $proxy -uri $uri -action $action \
                -params {inputIntegerArray int()}
        SOAP::create echoFloatArray -proxy $proxy -uri $uri -action $action \
                -params {inputFloatArray float()}
        SOAP::create echoStructArray -proxy $proxy -uri $uri -action $action \
                -params {inputStructArray SOAPStruct()}

        SOAP::create echoBase64 -proxy $proxy -uri $uri -action $action \
                -params {inputBase64 base64}
        SOAP::create echoDate -proxy $proxy -uri $uri -action $action \
                -params {inputDate timeInstant}
        SOAP::create echoVoid -proxy $proxy -uri $uri -action $action \
                -params {}
    }

    proc test_local {} {
        create http://localhost/cgi-bin/rpc
    }

    proc test_4s4c {} {
        create http://soap.4s4c.com/ilab/soap.asp
    }

    test_4s4c
}

proc soapinterop::validate {{proxy {}}} {
    if {$proxy != {}} {
	create $proxy
    }

    catch {validate.echoVoid} msg        ; puts "$msg"
    catch {validate.echoDate} msg        ; puts "$msg"
    catch {validate.echoInteger} msg     ; puts "$msg"
    catch {validate.echoFloat} msg       ; puts "$msg"
    catch {validate.echoString} msg      ; puts "$msg"
    catch {validate.echoIntegerArray} msg; puts "$msg"
    catch {validate.echoFloatArray} msg  ; puts "$msg"
    catch {validate.echoStringArray} msg ; puts "$msg"
    catch {validate.echoStruct} msg      ; puts "$msg"
    catch {validate.echoStructArray} msg ; puts "$msg"
}

proc soapinterop::rand_float {} {
    set r [expr rand() * 200 - 100]
    set p [string first . $r]
    incr p 4
    return [string range $r 0 $p]
}

proc soapinterop::rand_int {} {
    return [expr int(rand() * 200 - 100) ]
}

proc soapinterop::validate.echoVoid {} {
    set r [echoVoid]
    if {$r != {}} { error "echoVoid failed" }
    return "echoVoid"
}

proc soapinterop::validate.echoDate {} {
    set d [clock format [clock seconds] -format {%Y-%m-%dT%H:%M:%S}]
    set r [echoDate $d]
    if {! [string match "$d*" $r]} {
	error "echoDate failed: $d != $r"
    }
    return "echoDate"
}

proc soapinterop::validate.echoInteger {} {
    set i [rand_int]
    set r [echoInteger $i]
    if {$i != $r} { error "echoInteger failed" }
    return "echoInteger"
}

# Tend to loose some decimal places. Check to ?? dp ??
proc soapinterop::validate.echoFloat {} {
    set f [rand_float]
    set r [echoFloat $f]
    if {[expr $f != $r]} {
	error "echoFloat failed: $f != $r" 
    }
    return "echoFloat"
}

proc soapinterop::validate.echoString {} {
    set s [array get ::tcl_platform]<commit_msg>Added validate.echoBase64 test.<commit_after># Client implementation of the SOAP Interoperability lab Round 1 Test Suite.

package require SOAP
package require XMLRPC
package require rpcvar

namespace eval soapinterop {
    variable uri    "http://soapinterop.org/"
    variable action "urn:soapinterop"

    rpcvar::typedef -namespace http://soapinterop.org/xsd { \
	    varString string \
	    varInt    int \
	    varFloat  float} SOAPStruct

    proc create {proxy} {
        variable uri
        variable action
        
        SOAP::create echoString  -proxy $proxy -uri $uri -action $action \
                -params {inputString string}
        SOAP::create echoInteger -proxy $proxy -uri $uri -action $action \
                -params {inputInteger int}
        SOAP::create echoFloat -proxy $proxy -uri $uri -action $action \
                -params {inputFloat float}
        SOAP::create echoStruct -proxy $proxy -uri $uri -action $action \
                -params {inputStruct SOAPStruct}
        
        SOAP::create echoStringArray -proxy $proxy -uri $uri -action $action \
                -params {inputStringArray string()}
        SOAP::create echoIntegerArray -proxy $proxy -uri $uri -action $action \
                -params {inputIntegerArray int()}
        SOAP::create echoFloatArray -proxy $proxy -uri $uri -action $action \
                -params {inputFloatArray float()}
        SOAP::create echoStructArray -proxy $proxy -uri $uri -action $action \
                -params {inputStructArray SOAPStruct()}

        SOAP::create echoBase64 -proxy $proxy -uri $uri -action $action \
                -params {inputBase64 base64}
        SOAP::create echoDate -proxy $proxy -uri $uri -action $action \
                -params {inputDate timeInstant}
        SOAP::create echoVoid -proxy $proxy -uri $uri -action $action \
                -params {}
    }

    proc test_local {} {
        create http://localhost/cgi-bin/rpc
    }

    proc test_4s4c {} {
        create http://soap.4s4c.com/ilab/soap.asp
    }

    test_4s4c
}

proc soapinterop::validate {{proxy {}}} {
    if {$proxy != {}} {
	create $proxy
    }

    catch {validate.echoVoid} msg        ; puts "$msg"
    catch {validate.echoDate} msg        ; puts "$msg"
    catch {validate.echoBase64} msg      ; puts "$msg"
    catch {validate.echoInteger} msg     ; puts "$msg"
    catch {validate.echoFloat} msg       ; puts "$msg"
    catch {validate.echoString} msg      ; puts "$msg"
    catch {validate.echoIntegerArray} msg; puts "$msg"
    catch {validate.echoFloatArray} msg  ; puts "$msg"
    catch {validate.echoStringArray} msg ; puts "$msg"
    catch {validate.echoStruct} msg      ; puts "$msg"
    catch {validate.echoStructArray} msg ; puts "$msg"
}

proc soapinterop::rand_float {} {
    set r [expr rand() * 200 - 100]
    set p [string first . $r]
    incr p 4
    return [string range $r 0 $p]
}

proc soapinterop::rand_int {} {
    return [expr int(rand() * 200 - 100) ]
}

proc soapinterop::validate.echoVoid {} {
    set r [echoVoid]
    if {$r != {}} { error "echoVoid failed" }
    return "echoVoid"
}

proc soapinterop::validate.echoDate {} {
    set d [clock format [clock seconds] -format {%Y-%m-%dT%H:%M:%S}]
    set r [echoDate $d]
    if {! [string match "$d*" $r]} {
	error "echoDate failed: $d != $r"
    }
    return "echoDate"
}

proc soapinterop::validate.echoBase64 {} {
    set q [base64::encode [array get ::tcl_platform]]
    set r [echoBase64 $q]
    if {![string match $q $r]} {
	error "echoBase64 failed: strings do not match"
    }
    return "echoBase64"
}

proc soapinterop::validate.echoInteger {} {
    set i [rand_int]
    set r [echoInteger $i]
    if {$i != $r} { error "echoInteger failed" }
    return "echoInteger"
}

# Tend to loose some decimal places. Check to ?? dp ??
proc soapinterop::validate.echoFloat {} {
    set f [rand_float]
    set r [echoFloat $f]
    if {[expr $f != $r]} {
	error "echoFloat failed: $f != $r" 
    }
    return "echoFloat"
}

proc soapinterop::validate.echoString {} {
    set s [array get ::tcl_platform]
{'fraction_non_alphanumeric': 0.1227846487313528, 'fraction_numerical': 0.008670151727655234, 'mean_word_length': 2.4119182253153544, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5181583', 'n_tokens_mistral': 2475, 'n_tokens_neox': 2395, 'n_words': 736}