Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | merged trunk |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | rfe-dcce437d7aa5e64a |
Files: | files | file ages | folders |
SHA3-256: |
b774fc382158c29a414caa07b8077854 |
User & Date: | oehhar 2017-11-03 15:18:19.563 |
Context
2017-11-03 15:51 | Documentation and formatting, Client.tcl now version 2.4.4 Closed-Leaf check-in: e11e603f89 user: oehhar tags: rfe-dcce437d7aa5e64a | |
2017-11-03 15:18 | merged trunk check-in: b774fc3821 user: oehhar tags: rfe-dcce437d7aa5e64a | |
2017-11-03 15:11 | Add some documentation (for me) on WSDL parsing namespaces in client mode check-in: f8d98804f8 user: oehhar tags: trunk | |
2017-04-10 17:46 | Removed exec flag check-in: d7b6d160c6 user: oehhar tags: rfe-dcce437d7aa5e64a | |
Changes
Changes to AOLserver.tcl.
︙ | ︙ | |||
108 109 110 111 112 113 114 | default { ns_return 200 text/plain "prefix = $prefix service = $service requestType = $requestType" } } } } | | | 108 109 110 111 112 113 114 115 | default { ns_return 200 text/plain "prefix = $prefix service = $service requestType = $requestType" } } } } package provide WS::AOLserver 2.4.0 |
Changes to ChannelServer.tcl.
︙ | ︙ | |||
50 51 52 53 54 55 56 | } } package require uri package require base64 package require html | | | 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | } } package require uri package require base64 package require html package provide WS::Channel 2.4.0 namespace eval ::WS::Channel { array set portInfo {} array set dataArray {} } |
︙ | ︙ |
Changes to ClientSide.tcl.
1 2 | ############################################################################### ## ## | | | 1 2 3 4 5 6 7 8 9 10 | ############################################################################### ## ## ## Copyright (c) 2016-2017, Harald Oehlmann ## ## Copyright (c) 2006-2013, Gerald W. Lester ## ## Copyright (c) 2008, Georgios Petasis ## ## Copyright (c) 2006, Visiprise Software, Inc ## ## Copyright (c) 2006, Arnulf Wiedemann ## ## Copyright (c) 2006, Colin McCormack ## ## Copyright (c) 2006, Rolf Ade ## ## Copyright (c) 2001-2006, Pat Thoyts ## |
︙ | ︙ | |||
37 38 39 40 41 42 43 | ## LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ## ## ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ## ## POSSIBILITY OF SUCH DAMAGE. ## ## ## ############################################################################### package require Tcl 8.4 | | | | | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | ## LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ## ## ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ## ## POSSIBILITY OF SUCH DAMAGE. ## ## ## ############################################################################### package require Tcl 8.4 package require WS::Utils 2.4 ; # dict, lassign package require tdom 0.8 package require http 2 package require log package require uri package provide WS::Client 2.4.3 namespace eval ::WS::Client { # register https only if not yet registered if {[catch { http::unregister https } lPortCmd]} { # not registered -> register on my own if {[catch { package require tls http::register https 443 [list ::tls::socket -ssl2 no -ssl3 no -tls1 yes] } err]} { log::log warning "No https support: $err" |
︙ | ︙ | |||
309 310 311 312 313 314 315 | set serviceInfo $serviceArr($serviceName) set validOptionList [array names options] lappend validOptionList location targetNamespace if {[lsearch -exact $validOptionList $item] == -1} { return -code error "Uknown option '$item' -- must be one of: [join $validOptionList {, }]" } | | | 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 | set serviceInfo $serviceArr($serviceName) set validOptionList [array names options] lappend validOptionList location targetNamespace if {[lsearch -exact $validOptionList $item] == -1} { return -code error "Uknown option '$item' -- must be one of: [join $validOptionList {, }]" } if {$value ne {}} { dict set serviceInfo $item $value set serviceArr($serviceName) $serviceInfo } return [dict get $serviceInfo $item] } |
︙ | ︙ | |||
468 469 470 471 472 473 474 | if {[lsearch -exact [dict get $serviceArr($serviceName) objList] $objectName] == -1} { dict lappend serviceArr($serviceName) objList $objectName } if {![llength $location]} { set location [dict get $serviceArr($serviceName) location] } | | | | 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 | if {[lsearch -exact [dict get $serviceArr($serviceName) objList] $objectName] == -1} { dict lappend serviceArr($serviceName) objList $objectName } if {![llength $location]} { set location [dict get $serviceArr($serviceName) location] } if {$inputArgs ne {}} { set inType $objectName.$operationName.Request ::WS::Utils::ServiceTypeDef Client $serviceName $inType $inputArgs } else { set inType {} } if {$returnType ne {}} { set outType $objectName.$operationName.Results ::WS::Utils::ServiceTypeDef Client $serviceName $outType $returnType } else { set outType {} } dict set serviceArr($serviceName) object $objectName location $location |
︙ | ︙ | |||
521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 | # Maintenance History - as this file is modified, please be sure that you # update this segment of the file header block by # adding a complete entry at the bottom of the list. # # Version Date Programmer Comments / Changes / Reasons # ------- ---------- ---------- ------------------------------------------- # 1 01/30/2009 G.Lester Initial version # # ########################################################################### proc ::WS::Client::ImportNamespace {serviceName url} { variable serviceArr switch -exact -- [dict get [::uri::split $url] scheme] { file { upvar #0 [::uri::geturl $url] token set xml $token(data) unset token } http - https { | > > > < < < | < < < < < < < | | 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 | # Maintenance History - as this file is modified, please be sure that you # update this segment of the file header block by # adding a complete entry at the bottom of the list. # # Version Date Programmer Comments / Changes / Reasons # ------- ---------- ---------- ------------------------------------------- # 1 01/30/2009 G.Lester Initial version # 2.4.1 2017-08-31 H.Oehlmann Use utility function # ::WS::Utils::geturl_fetchbody for http call # which also follows redirects. # # ########################################################################### proc ::WS::Client::ImportNamespace {serviceName url} { variable serviceArr switch -exact -- [dict get [::uri::split $url] scheme] { file { upvar #0 [::uri::geturl $url] token set xml $token(data) unset token } http - https { set xml [::WS::Utils::geturl_fetchbody $url] } default { return \ -code error \ -errorcode [list WS CLIENT UNKURLTYP $url] \ "Unknown URL type '$url'" } } set tnsCount [expr {[llength [dict get $serviceArr($serviceName) targetNamespace]]/2}] set serviceInfo $serviceArr($serviceName) dict lappend serviceInfo imports $url ::WS::Utils::ProcessImportXml Client $url $xml $serviceName serviceInfo tnsCount set serviceArr($serviceName) $serviceInfo set result {} foreach {result target} [dict get $serviceArr($serviceName) targetNamespace] { if {$target eq $url} { break } } return $result } ########################################################################### |
︙ | ︙ | |||
607 608 609 610 611 612 613 | # 1 01/30/2009 G.Lester Initial version # # ########################################################################### proc ::WS::Client::GetOperationList {serviceName {object {}}} { variable serviceArr | | | 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 | # 1 01/30/2009 G.Lester Initial version # # ########################################################################### proc ::WS::Client::GetOperationList {serviceName {object {}}} { variable serviceArr if {$object eq {}} { return [dict get $serviceArr($serviceName) operList] } else { return [list $object [dict get $serviceArr($serviceName) operation $object inputs] [dict get $serviceArr($serviceName) operation $object outputs]] } } |
︙ | ︙ | |||
676 677 678 679 680 681 682 | # Public Procedure Header - as this procedure is modified, please be sure # that you update this header block. Thanks. # #>>BEGIN PUBLIC<< # # Procedure Name : ::WS::Client::AddOutputHeader # | | | 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 | # Public Procedure Header - as this procedure is modified, please be sure # that you update this header block. Thanks. # #>>BEGIN PUBLIC<< # # Procedure Name : ::WS::Client::AddOutputHeader # # Description : Import any additional namespace into the service # # Arguments : # serviceName - Service name to of the oepration # operation - name of operation to add an output header to # headerType - the type name to add as a header # attrList - list of name value pairs of attributes and their # values to add to the XML |
︙ | ︙ | |||
711 712 713 714 715 716 717 | # # ########################################################################### proc ::WS::Client::AddOutputHeader {serviceName operation headerType} { variable serviceArr set serviceInfo $serviceArr($serviceName) | | | | | 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 | # # ########################################################################### proc ::WS::Client::AddOutputHeader {serviceName operation headerType} { variable serviceArr set serviceInfo $serviceArr($serviceName) set soapReplyHeader [dict get $serviceInfo operation $operation soapReplyHeader] lappend soapReplyHeader $headerType dict set serviceInfo operation $operation soapReplyHeader $soapReplyHeader set serviceArr($serviceName) $serviceInfo return } ########################################################################### # # Public Procedure Header - as this procedure is modified, please be sure |
︙ | ︙ | |||
840 841 842 843 844 845 846 | set serviceArr($serviceName) $serviceInfo if {[dict exists $serviceInfo types]} { foreach {typeName partList} [dict get $serviceInfo types] { set definition [dict get $partList definition] set xns [dict get $partList xns] set isAbstarct [dict get $partList abstract] | | | | 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 | set serviceArr($serviceName) $serviceInfo if {[dict exists $serviceInfo types]} { foreach {typeName partList} [dict get $serviceInfo types] { set definition [dict get $partList definition] set xns [dict get $partList xns] set isAbstarct [dict get $partList abstract] if {[lindex [split $typeName {:}] 1] eq {}} { ::WS::Utils::ServiceTypeDef Client $serviceName $typeName $definition tns1 $isAbstarct } else { #set typeName [lindex [split $typeName {:}] 1] ::WS::Utils::ServiceTypeDef Client $serviceName $typeName $definition $xns $isAbstarct } } } if {[dict exists $serviceInfo simpletypes]} { foreach partList [dict get $serviceInfo simpletypes] { lassign $partList typeName definition if {[lindex [split $typeName {:}] 1] eq {}} { ::WS::Utils::ServiceSimpleTypeDef Client $serviceName $typeName $definition tns1 } else { set xns [lindex [split $typeName {:}] 0] #set typeName [lindex [split $typeName {:}] 1] ::WS::Utils::ServiceSimpleTypeDef Client $serviceName $typeName $definition $xns } } |
︙ | ︙ | |||
908 909 910 911 912 913 914 | # Maintenance History - as this file is modified, please be sure that you # update this segment of the file header block by # adding a complete entry at the bottom of the list. # # Version Date Programmer Comments / Changes / Reasons # ------- ---------- ---------- ------------------------------------------- # 1 07/06/2006 G.Lester Initial version | | > | | < < < < < < < < < < < | < | 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 | # Maintenance History - as this file is modified, please be sure that you # update this segment of the file header block by # adding a complete entry at the bottom of the list. # # Version Date Programmer Comments / Changes / Reasons # ------- ---------- ---------- ------------------------------------------- # 1 07/06/2006 G.Lester Initial version # 2.4.1 2017-08-31 H.Oehlmann Use utility function # ::WS::Utils::geturl_fetchbody for http call # ########################################################################### proc ::WS::Client::GetAndParseWsdl {url {headers {}} {serviceAlias {}}} { variable currentBaseUrl set currentBaseUrl $url switch -exact -- [dict get [::uri::split $url] scheme] { file { upvar #0 [::uri::geturl $url] token set wsdlInfo [ParseWsdl $token(data) -headers $headers -serviceAlias $serviceAlias] unset token } http - https { if {[llength $headers]} { set body [::WS::Utils::geturl_fetchbody $url -headers $headers] } else { set body [::WS::Utils::geturl_fetchbody $url] } set wsdlInfo [ParseWsdl $body -headers $headers -serviceAlias $serviceAlias] } default { return \ -code error \ -errorcode [list WS CLIENT UNKURLTYP $url] \ "Unknown URL type '$url'" } |
︙ | ︙ | |||
1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 | set first [string first {<} $wsdlXML] if {$first > 0} { set wsdlXML [string range $wsdlXML $first end] } ::log::log debug "Parsing WSDL {$wsdlXML}" dom parse $wsdlXML tmpdoc $tmpdoc xslt $::WS::Utils::xsltSchemaDom wsdlDoc $tmpdoc delete $wsdlDoc documentElement wsdlNode set nsCount 1 set targetNs [$wsdlNode getAttribute targetNamespace] set ::WS::Utils::targetNs $targetNs dict set nsDict url $targetNs tns$nsCount $wsdlDoc selectNodesNamespaces { w http://schemas.xmlsoap.org/wsdl/ d http://schemas.xmlsoap.org/wsdl/soap/ xs http://www.w3.org/2001/XMLSchema } | > > > > > > > > > > > > > > > > > > > > > > > > > | 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 | set first [string first {<} $wsdlXML] if {$first > 0} { set wsdlXML [string range $wsdlXML $first end] } ::log::log debug "Parsing WSDL {$wsdlXML}" # save parsed document node to tmpdoc dom parse $wsdlXML tmpdoc # save transformed document handle in variable wsdlDoc $tmpdoc xslt $::WS::Utils::xsltSchemaDom wsdlDoc $tmpdoc delete # save top node in variable wsdlNode $wsdlDoc documentElement wsdlNode set nsCount 1 set targetNs [$wsdlNode getAttribute targetNamespace] set ::WS::Utils::targetNs $targetNs ## ## Build the namespace prefix dict ## # nsDict contains two tables: # 1) Lookup URI, get internal prefix # url <URI> <tns> # 2) Lookup wsdl namespace prefix, get internal namespace prefix # tns <ns> <tns> # <URI>: unique ID, mostly URL # <ns>: namespace prefix used in wsdl # <tns> internal namespace prefix which allows to use predefined prefixes # not to clash with the wsdl prefix in <ns> # Predefined: # - tns1 : targetNamespace # - w: http://schemas.xmlsoap.org/wsdl/ # - d: http://schemas.xmlsoap.org/wsdl/soap/ # - xs: http://www.w3.org/2001/XMLSchema # # The top node <wsdl:definitions # targetNamespace="http://www.webserviceX.NET/"> # xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/ ...> # contains the target namespace and all namespace definitions dict set nsDict url $targetNs tns$nsCount $wsdlDoc selectNodesNamespaces { w http://schemas.xmlsoap.org/wsdl/ d http://schemas.xmlsoap.org/wsdl/soap/ xs http://www.w3.org/2001/XMLSchema } |
︙ | ︙ | |||
1182 1183 1184 1185 1186 1187 1188 | if {[dict get $serviceInfo operation $operationName cloned]} { continue } set procName [format {::%s::%s} $serviceName $operationName] set argList {} foreach inputHeaderTypeItem [dict get $serviceInfo operation $operationName soapRequestHeader] { set inputHeaderType [lindex $inputHeaderTypeItem 0] | | | | | 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 | if {[dict get $serviceInfo operation $operationName cloned]} { continue } set procName [format {::%s::%s} $serviceName $operationName] set argList {} foreach inputHeaderTypeItem [dict get $serviceInfo operation $operationName soapRequestHeader] { set inputHeaderType [lindex $inputHeaderTypeItem 0] if {$inputHeaderType eq {}} { continue } set headerTypeInfo [::WS::Utils::GetServiceTypeDef Client $serviceName $inputHeaderType] set headerFields [dict keys [dict get $headerTypeInfo definition]] if {$headerFields ne {}} { lappend argList [lsort -dictionary $headerFields] } } set inputMsgType [dict get $serviceInfo operation $operationName inputs] ## Petasis, 14 July 2008: If an input message has no elements, just do ## not add any arguments... set inputMsgTypeDefinition [::WS::Utils::GetServiceTypeDef Client $serviceName $inputMsgType] if {[dict exists $inputMsgTypeDefinition definition]} { set inputFields [dict keys [dict get $inputMsgTypeDefinition definition]] } else { ::log::log debug "no definition found for inputMsgType $inputMsgType" set inputFields {} } if {$inputFields ne {}} { lappend argList [lsort -dictionary $inputFields] } set argList [join $argList] set body { set procName [lindex [info level 0] 0] set serviceName [string trim [namespace qualifiers $procName] {:}] |
︙ | ︙ | |||
1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 | # Maintenance History - as this file is modified, please be sure that you # update this segment of the file header block by # adding a complete entry at the bottom of the list. # # Version Date Programmer Comments / Changes / Reasons # ------- ---------- ---------- ------------------------------------------- # 1 07/06/2006 G.Lester Initial version # # ########################################################################### proc ::WS::Client::DoRawCall {serviceName operationName argList {headers {}}} { variable serviceArr ::log::log debug "Entering ::WS::Client::DoRawCall {$serviceName $operationName $argList}" if {![info exists serviceArr($serviceName)]} { return \ -code error \ -errorcode [list WS CLIENT UNKSRV $serviceName] \ "Unknown service '$serviceName'" } set serviceInfo $serviceArr($serviceName) if {![dict exists $serviceInfo operation $operationName]} { return \ -code error \ -errorcode [list WS CLIENT UNKOPER [list $serviceName $operationName]] \ "Unknown operation '$operationName' for service '$serviceName'" } set url [dict get $serviceInfo location] SaveAndSetOptions $serviceName if {[catch {set query [buildCallquery $serviceName $operationName $url $argList]} err]} { RestoreSavedOptions $serviceName return -code error -errorcode $::errorCode -errorinfo $::errorInfo $err } else { RestoreSavedOptions $serviceName } if {[dict exists $serviceInfo headers]} { set headers [concat $headers [dict get $serviceInfo headers]] } if {[dict exists $serviceInfo operation $operationName action]} { lappend headers SOAPAction [format {"%s"} [dict get $serviceInfo operation $operationName action]] } | > > > > > > > > < < < < < < | < < | | < | < < < < < > < < > | < < < < < < < < | | < | 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 | # Maintenance History - as this file is modified, please be sure that you # update this segment of the file header block by # adding a complete entry at the bottom of the list. # # Version Date Programmer Comments / Changes / Reasons # ------- ---------- ---------- ------------------------------------------- # 1 07/06/2006 G.Lester Initial version # 2.4.1 2017-08-31 H.Oehlmann Use utility function # ::WS::Utils::geturl_fetchbody for http call # which also follows redirects. # # ########################################################################### proc ::WS::Client::DoRawCall {serviceName operationName argList {headers {}}} { variable serviceArr ::log::log debug "Entering ::WS::Client::DoRawCall {$serviceName $operationName $argList}" if {![info exists serviceArr($serviceName)]} { return \ -code error \ -errorcode [list WS CLIENT UNKSRV $serviceName] \ "Unknown service '$serviceName'" } set serviceInfo $serviceArr($serviceName) if {![dict exists $serviceInfo operation $operationName]} { return \ -code error \ -errorcode [list WS CLIENT UNKOPER [list $serviceName $operationName]] \ "Unknown operation '$operationName' for service '$serviceName'" } ## ## build query ## set url [dict get $serviceInfo location] SaveAndSetOptions $serviceName if {[catch {set query [buildCallquery $serviceName $operationName $url $argList]} err]} { RestoreSavedOptions $serviceName return -code error -errorcode $::errorCode -errorinfo $::errorInfo $err } else { RestoreSavedOptions $serviceName } if {[dict exists $serviceInfo headers]} { set headers [concat $headers [dict get $serviceInfo headers]] } if {[dict exists $serviceInfo operation $operationName action]} { lappend headers SOAPAction [format {"%s"} [dict get $serviceInfo operation $operationName action]] } ## ## do http call ## if {[llength $headers]} { set body [::WS::Utils::geturl_fetchbody $url -query $query -type [dict get $serviceInfo contentType] -headers $headers] } else { set body [::WS::Utils::geturl_fetchbody $url -query $query -type [dict get $serviceInfo contentType]] } ::log::log debug "Leaving ::WS::Client::DoRawCall with {$body}" return $body } ########################################################################### # # Public Procedure Header - as this procedure is modified, please be sure # that you update this header block. Thanks. |
︙ | ︙ | |||
1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 | # Maintenance History - as this file is modified, please be sure that you # update this segment of the file header block by # adding a complete entry at the bottom of the list. # # Version Date Programmer Comments / Changes / Reasons # ------- ---------- ---------- ------------------------------------------- # 1 07/06/2006 G.Lester Initial version # # ########################################################################### proc ::WS::Client::DoCall {serviceName operationName argList {headers {}}} { variable serviceArr ::log::log debug "Entering ::WS::Client::DoCall {$serviceName $operationName $argList}" | > > > | 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 | # Maintenance History - as this file is modified, please be sure that you # update this segment of the file header block by # adding a complete entry at the bottom of the list. # # Version Date Programmer Comments / Changes / Reasons # ------- ---------- ---------- ------------------------------------------- # 1 07/06/2006 G.Lester Initial version # 2.4.1 2017-08-30 H.Oehlmann Use ::WS::Utils::geturl_fetchbody to do # http call. This automates a lot and follows # redirects. # # ########################################################################### proc ::WS::Client::DoCall {serviceName operationName argList {headers {}}} { variable serviceArr ::log::log debug "Entering ::WS::Client::DoCall {$serviceName $operationName $argList}" |
︙ | ︙ | |||
1427 1428 1429 1430 1431 1432 1433 1434 | } if {[dict exists $serviceInfo headers]} { set headers [concat $headers [dict get $serviceInfo headers]] } if {[dict exists $serviceInfo operation $operationName action]} { lappend headers SOAPAction [format {"%s"} [dict get $serviceInfo operation $operationName action]] } if {[llength $headers]} { | > > > > > < | < | | | < < < < | > > | | < < < < < < < < < < | | < | 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 | } if {[dict exists $serviceInfo headers]} { set headers [concat $headers [dict get $serviceInfo headers]] } if {[dict exists $serviceInfo operation $operationName action]} { lappend headers SOAPAction [format {"%s"} [dict get $serviceInfo operation $operationName action]] } ## ## Do the http request ## # This will directly return with correct error # side effect: sets the variable httpCode if {[llength $headers]} { set body [::WS::Utils::geturl_fetchbody -codeok {200 500} -codevar httpCode $url -query $query -type [dict get $serviceInfo contentType] -headers $headers] } else { set body [::WS::Utils::geturl_fetchbody -codeok {200 500} -codevar httpCode $url -query $query -type [dict get $serviceInfo contentType] ] } # numerical http code was saved in variable httpCode ## ## Process body ## set outTransform [dict get $serviceInfo outTransform] if {$httpCode == 500} { ## Code 500 treatment if {$outTransform ne {}} { SaveAndSetOptions $serviceName catch {set body [$outTransform $serviceName $operationName REPLY $body]} RestoreSavedOptions $serviceName } set hadError [catch {parseResults $serviceName $operationName $body} results] if {$hadError} { lassign $::errorCode mainError subError if {$mainError eq {WSCLIENT} && $subError eq {NOSOAP}} { ::log::log debug "\tHTTP error $body" set results $body set errorCode [list WSCLIENT HTTPERROR $body] set errorInfo {} } else { ::log::log debug "Reply was $body" set errorCode $::errorCode set errorInfo $::errorInfo } } } else { if {$outTransform ne {}} { SaveAndSetOptions $serviceName catch {set body [$outTransform $serviceName $operationName REPLY $body]} RestoreSavedOptions $serviceName } SaveAndSetOptions $serviceName set hadError [catch {parseResults $serviceName $operationName $body} results] RestoreSavedOptions $serviceName if {$hadError} { ::log::log debug "Reply was $body" set errorCode $::errorCode set errorInfo $::errorInfo } } if {$hadError} { ::log::log debug "Leaving (error) ::WS::Client::DoCall" return \ -code error \ -errorcode $errorCode \ -errorinfo $errorInfo \ $results |
︙ | ︙ | |||
1542 1543 1544 1545 1546 1547 1548 | # Version Date Programmer Comments / Changes / Reasons # ------- ---------- ---------- ------------------------------------------- # 1 06/02/2015 H.Oehlmann Initial version # # ########################################################################### proc ::WS::Client::FormatHTTPError {token} { | | | 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 | # Version Date Programmer Comments / Changes / Reasons # ------- ---------- ---------- ------------------------------------------- # 1 06/02/2015 H.Oehlmann Initial version # # ########################################################################### proc ::WS::Client::FormatHTTPError {token} { if {[::http::status $token] eq {ok}} { if {[::http::size $token] == 0} { return "HTTP failure socket closed" } return "HTTP failure code [::http::ncode $token]" } else { return "HTTP error: [::http::error $token]" } |
︙ | ︙ | |||
1725 1726 1727 1728 1729 1730 1731 | if {[dict get $serviceInfo operation $operationName cloned]} { continue } set procName $operationName set argList {} foreach inputHeaderTypeItem [dict get $serviceInfo operation $operationName soapRequestHeader] { set inputHeaderType [lindex $inputHeaderTypeItem 0] | | | | | | 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 | if {[dict get $serviceInfo operation $operationName cloned]} { continue } set procName $operationName set argList {} foreach inputHeaderTypeItem [dict get $serviceInfo operation $operationName soapRequestHeader] { set inputHeaderType [lindex $inputHeaderTypeItem 0] if {$inputHeaderType eq {}} { continue } set headerTypeInfo [::WS::Utils::GetServiceTypeDef Client $serviceName $inputHeaderType] set headerFields [dict keys [dict get $headerTypeInfo definition]] if {$headerFields ne {}} { lappend argList [lsort -dictionary $headerFields] } } set inputMsgType [dict get $serviceInfo operation $operationName inputs] if {$inputMsgType ne {}} { set inTypeDef [::WS::Utils::GetServiceTypeDef Client $serviceName $inputMsgType] if {[dict exists $inTypeDef definition]} { set inputFields [dict keys [dict get $inTypeDef definition]] if {$inputFields ne {}} { lappend argList [lsort -dictionary $inputFields] } } } set argList [join $argList] append procList "\n\t$procName $argList" |
︙ | ︙ | |||
1810 1811 1812 1813 1814 1815 1816 | foreach object [dict get $serviceInfo objList] { foreach operationName [dict keys [dict get $serviceInfo object $object operations]] { set procName $operationName set argList {} foreach inputHeaderTypeItem [dict get $serviceInfo operation $operationName soapRequestHeader] { set inputHeaderType [lindex $inputHeaderTypeItem 0] | | | | | 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 | foreach object [dict get $serviceInfo objList] { foreach operationName [dict keys [dict get $serviceInfo object $object operations]] { set procName $operationName set argList {} foreach inputHeaderTypeItem [dict get $serviceInfo operation $operationName soapRequestHeader] { set inputHeaderType [lindex $inputHeaderTypeItem 0] if {$inputHeaderType eq {}} { continue } set headerTypeInfo [::WS::Utils::GetServiceTypeDef Client $serviceName $inputHeaderType] set headerFields [dict keys [dict get $headerTypeInfo definition]] if {$headerFields ne {}} { lappend argList [lsort -dictionary $headerFields] } } set inputMsgType [dict get $serviceInfo operation $operationName inputs] set inputFields [dict keys [dict get [::WS::Utils::GetServiceTypeDef Client $serviceName $inputMsgType] definition]] if {$inputFields ne {}} { lappend argList [lsort -dictionary $inputFields] } set argList [join $argList] append procList "\n\t$object $procName $argList" } } |
︙ | ︙ | |||
1885 1886 1887 1888 1889 1890 1891 | ## ## Check for errors ## set body [::http::data $token] ::log::log info "\nReceived: $body" set results {} | | | | 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 | ## ## Check for errors ## set body [::http::data $token] ::log::log info "\nReceived: $body" set results {} if {[::http::status $token] ne {ok} || ( [::http::ncode $token] != 200 && $body eq {} )} { set errorCode [list WS CLIENT HTTPERROR [::http::code $token]] set hadError 1 set errorInfo [FormatHTTPError $token] } else { SaveAndSetOptions $serviceName if {[catch {set hadError [catch {parseResults $serviceName $operationName $body} results]} err]} { RestoreSavedOptions $serviceName |
︙ | ︙ | |||
1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 | # Maintenance History - as this file is modified, please be sure that you # update this segment of the file header block by # adding a complete entry at the bottom of the list. # # Version Date Programmer Comments / Changes / Reasons # ------- ---------- ---------- ------------------------------------------- # 1 07/06/2006 G.Lester Initial version # # ########################################################################### proc ::WS::Client::parseResults {serviceName operationName inXML} { variable serviceArr ::log::log debug "In parseResults $serviceName $operationName {$inXML}" set serviceInfo $serviceArr($serviceName) set expectedMsgType [dict get $serviceInfo operation $operationName outputs] set expectedMsgTypeBase [lindex [split $expectedMsgType {:}] end] set first [string first {<} $inXML] if {$first > 0} { set inXML [string range $inXML $first end] } dom parse $inXML doc $doc documentElement top set xns { ENV http://schemas.xmlsoap.org/soap/envelope/ xsi "http://www.w3.org/2001/XMLSchema-instance" xs "http://www.w3.org/2001/XMLSchema" } foreach tmp [dict get $serviceInfo targetNamespace] { lappend xns $tmp } ::log::log debug "Using namespaces {$xns}" $doc selectNodesNamespaces $xns set body [$top selectNodes ENV:Body] if {![llength $body]} { return \ -code error \ -errorcode [list WS CLIENT BADREPLY $inXML] \ "Bad reply type, no SOAP envelope received in: \n$inXML" } | > > > > > > > > > > > | > > > > | < | < | | | > > > > > > > > > > > > > > > > > > > > > > | | < > > > > > > > > | | > > > > > > | > | | | > > | | > | > | > > > > < | | | < < < < < < < < < < < | | | 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 | # Maintenance History - as this file is modified, please be sure that you # update this segment of the file header block by # adding a complete entry at the bottom of the list. # # Version Date Programmer Comments / Changes / Reasons # ------- ---------- ---------- ------------------------------------------- # 1 07/06/2006 G.Lester Initial version # 2.4.2 2017-08-31 H.Oehlmann The response node name may also be the # output name and not only the output type. # (ticket [21f41e22bc]). # 2.4.3 2017-11-03 H.Oehlmann Extended upper commit also to search # for multiple child nodes. # # ########################################################################### proc ::WS::Client::parseResults {serviceName operationName inXML} { variable serviceArr ::log::log debug "In parseResults $serviceName $operationName {$inXML}" set serviceInfo $serviceArr($serviceName) set expectedMsgType [dict get $serviceInfo operation $operationName outputs] set expectedMsgTypeBase [lindex [split $expectedMsgType {:}] end] set first [string first {<} $inXML] if {$first > 0} { set inXML [string range $inXML $first end] } # parse xml and save handle in variable doc and free it when out of scope dom parse $inXML doc # save top node handle in variable top and free it if out of scope $doc documentElement top set xns { ENV http://schemas.xmlsoap.org/soap/envelope/ xsi "http://www.w3.org/2001/XMLSchema-instance" xs "http://www.w3.org/2001/XMLSchema" } foreach tmp [dict get $serviceInfo targetNamespace] { lappend xns $tmp } ::log::log debug "Using namespaces {$xns}" $doc selectNodesNamespaces $xns set body [$top selectNodes ENV:Body] if {![llength $body]} { return \ -code error \ -errorcode [list WS CLIENT BADREPLY $inXML] \ "Bad reply type, no SOAP envelope received in: \n$inXML" } ## ## Find the reply root node with the response. ## # <SOAP-ENV:Envelope...> # <SOAP-ENV:Body> # <i2:TestResponse id="ref-1" xmlns:i2=...> <-- this one # # WSDL 1.0: http://xml.coverpages.org/wsdl20000929.html # Chapter 2.4.2 (name optional) and 2.4.5 (default name) # The node name could be: # 1) an error node "Fault" # 2) equal to the WSDL name property of the output node # 3) if no name tag, equal to <Operation>Response # 4) the local output type name # # Possibility (2) "OutName" WSDL example: # <wsdl:portType...><wsdl:operation...> # <wsdl:output name="{OutName}" message="tns:{OutMsgName}" /> # This possibility is requested by ticket [21f41e22bc] # # Possibility (3) default name "{OperationName}Result" WSDL example: # <wsdl:portType...><wsdl:operation name="{OperationName}"> # <wsdl:output message="tns:{OutMsgName}" /> *** no name tag *** # # Possibility (4) was not found in wsdl 1.0 standard but was used as only # solution by TCLWS prior to 2.4.2. # The following sketch shows the location of the local output type name # "OutTypeName" in a WSDL file: # -> In WSDL portType output message name # <wsdl:portType...><wsdl:operation...> # <wsdl:output message="tns:{OutMsgName}" /> # -> then in message, use the element: # <wsdl:message name="{OutMsgName}"> # <wsdl:part name="..." element="tns:<{OutTypeName}>" /> # -> The element "OutTypeName" is also find in a type definition: # <wsdl:types> # <s:element name="{OutMsgName}"> # <s:complexType>... # # Build a list of possible names set nodeNameCandidateList [list Fault $expectedMsgTypeBase] # We check if the preparsed wsdl contains the name flag. # This is not the case, if it was parsed with tclws prior 2.4.2 # *** ToDo *** This security may be removed on a major release if {[dict exists $serviceInfo operation $operationName outputsname]} { lappend nodeNameCandidateList [dict get $serviceInfo operation $operationName outputsname] } set rootNodeList [$body childNodes] ::log::log debug "Have [llength $rootNodeList] node under Body" foreach rootNodeCur $rootNodeList { set rootNameCur [$rootNodeCur localName] if {$rootNameCur eq {}} { set rootNameCur [$rootNodeCur nodeName] } if {$rootNameCur in $nodeNameCandidateList} { set rootNode $rootNodeCur set rootName $rootNameCur ::log::log debug "Result root name is '$rootName'" break } ::log::log debug "Result root name '$rootNameCur' not in candidates '$nodeNameCandidateList'" } ## ## Exit if there is no such node ## if {![info exists rootName]} { return \ -code error \ -errorcode [list WS CLIENT BADREPLY [list $rootName $expectedMsgTypeBase]] \ "Bad reply type, received '$rootName'; but expected '$expectedMsgTypeBase'." } ## ## See if it is a standard error packet ## if {$rootName eq {Fault}} { set faultcode {} set faultstring {} set detail {} foreach item {faultcode faultstring detail} { set tmpNode [$rootNode selectNodes ENV:$item] if {$tmpNode eq {}} { set tmpNode [$rootNode selectNodes $item] } if {$tmpNode ne {}} { if {[$tmpNode hasAttribute href]} { set tmpNode [GetReferenceNode $top [$tmpNode getAttribute href]] } set $item [$tmpNode asText] } } $doc delete return \ -code error \ -errorcode [list WS CLIENT REMERR $faultcode] \ -errorinfo $detail \ $faultstring } ## ## Convert the packet to a dictionary ## set results {} set headerRootNode [$top selectNodes ENV:Header] if {[llength $headerRootNode]} { foreach outHeaderType [dict get $serviceInfo operation $operationName soapReplyHeader] { if {$outHeaderType eq {}} { continue } set xns [dict get [::WS::Utils::GetServiceTypeDef Client $serviceName $outHeaderType] xns] set node [$headerRootNode selectNodes $outHeaderType] if {![llength $node]} { set node [$headerRootNode selectNodes $xns:$outHeaderType] if {![llength $node]} { continue } } #if {[llength $outHeaderAttrs]} { # ::WS::Utils::setAttr $node $outHeaderAttrs #} ::log::log debug "Calling [list ::WS::Utils::convertTypeToDict Client $serviceName $node $outHeaderType $headerRootNode]" lappend results [::WS::Utils::convertTypeToDict Client $serviceName $node $outHeaderType $headerRootNode] } } ::log::log debug "Calling [list ::WS::Utils::convertTypeToDict Client $serviceName $rootNode $expectedMsgType $body]" if {$rootName ne {}} { set bodyData [::WS::Utils::convertTypeToDict \ Client $serviceName $rootNode $expectedMsgType $body] if {![llength $bodyData] && ([dict get $serviceInfo skipLevelWhenActionPresent] || [dict get $serviceInfo skipLevelOnReply])} { ::log::log debug "Calling [list ::WS::Utils::convertTypeToDict Client $serviceName $rootNode $expectedMsgType $body] -- skipLevelWhenActionPresent was set" set bodyData [::WS::Utils::convertTypeToDict \ Client $serviceName $body $expectedMsgType $body] } |
︙ | ︙ | |||
2177 2178 2179 2180 2181 2182 2183 | -code error "Unsupported Style '$style'" } } ::WS::Utils::SetOption suppressNS $inSuppressNs set inTransform [dict get $serviceInfo inTransform] | | | 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 | -code error "Unsupported Style '$style'" } } ::WS::Utils::SetOption suppressNS $inSuppressNs set inTransform [dict get $serviceInfo inTransform] if {$inTransform ne {}} { set xml [$inTransform $serviceName $operationName REQUEST $xml $url $argList] } ::log::log debug "Leaving ::WS::Client::buildCallquery with {$xml}" return $xml } |
︙ | ︙ | |||
2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 | ::log::log debug "Entering [info level 0]" set serviceInfo $serviceArr($serviceName) set msgType [dict get $serviceInfo operation $operationName inputs] set url [dict get $serviceInfo location] set xnsList [dict get $serviceInfo targetNamespace] dom createDocument "SOAP-ENV:Envelope" doc $doc documentElement env $env setAttribute \ "xmlns:SOAP-ENV" "http://schemas.xmlsoap.org/soap/envelope/" \ "xmlns:SOAP-ENC" "http://schemas.xmlsoap.org/soap/encoding/" \ "xmlns:xsi" "http://www.w3.org/2001/XMLSchema-instance" \ "xmlns:xs" "http://www.w3.org/2001/XMLSchema" | > | 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 | ::log::log debug "Entering [info level 0]" set serviceInfo $serviceArr($serviceName) set msgType [dict get $serviceInfo operation $operationName inputs] set url [dict get $serviceInfo location] set xnsList [dict get $serviceInfo targetNamespace] # save the document in variable doc and free it if out of scope dom createDocument "SOAP-ENV:Envelope" doc $doc documentElement env $env setAttribute \ "xmlns:SOAP-ENV" "http://schemas.xmlsoap.org/soap/envelope/" \ "xmlns:SOAP-ENC" "http://schemas.xmlsoap.org/soap/encoding/" \ "xmlns:xsi" "http://www.w3.org/2001/XMLSchema-instance" \ "xmlns:xs" "http://www.w3.org/2001/XMLSchema" |
︙ | ︙ | |||
2264 2265 2266 2267 2268 2269 2270 | xmlns:$tns $target } #parray tnsArray set firstHeader 1 foreach inputHeaderTypeItem [dict get $serviceInfo operation $operationName soapRequestHeader] { lassign $inputHeaderTypeItem inputHeaderType attrList | | > > | 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 | xmlns:$tns $target } #parray tnsArray set firstHeader 1 foreach inputHeaderTypeItem [dict get $serviceInfo operation $operationName soapRequestHeader] { lassign $inputHeaderTypeItem inputHeaderType attrList if {$inputHeaderType eq {}} { continue } set xns [dict get [::WS::Utils::GetServiceTypeDef Client $serviceName $inputHeaderType] xns] if {[info exists tnsArray($xns)]} { set xns $tnsArray($xns) } if {$firstHeader} { # side effect: save new node handle in variable header $env appendChild [$doc createElement "SOAP-ENV:Header" header] set firstHeader 0 } if {[dict exists $serviceInfo skipHeaderLevel] && [dict get $serviceInfo skipHeaderLevel]} { set headerData $header } else { set typeInfo [split $inputHeaderType {:}] if {[llength $typeInfo] > 1} { set headerType $inputHeaderType } else { set headerType $xns:$inputHeaderType } $header appendChild [$doc createElement $headerType headerData] if {[llength $attrList]} { ::WS::Utils::setAttr $headerData $attrList } } ::WS::Utils::convertDictToType Client $serviceName $doc $headerData $argList $inputHeaderType } # side effect: save new element handle in variable bod $env appendChild [$doc createElement "SOAP-ENV:Body" bod] #puts "set xns \[dict get \[::WS::Utils::GetServiceTypeDef Client $serviceName $msgType\] xns\]" #puts "\t [::WS::Utils::GetServiceTypeDef Client $serviceName $msgType]" set xns [dict get [::WS::Utils::GetServiceTypeDef Client $serviceName $msgType] xns] if {[info exists tnsArray($xns)]} { set xns $tnsArray($xns) } |
︙ | ︙ | |||
2388 2389 2390 2391 2392 2393 2394 | foreach {tns target} $xnsList { $env setAttribute xmlns:$tns $target } set firstHeader 1 foreach inputHeaderType [dict get $serviceInfo operation $operationName soapRequestHeader] { | | > | 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 | foreach {tns target} $xnsList { $env setAttribute xmlns:$tns $target } set firstHeader 1 foreach inputHeaderType [dict get $serviceInfo operation $operationName soapRequestHeader] { if {$inputHeaderType eq {}} { continue } set xns [dict get [::WS::Utils::GetServiceTypeDef Client $serviceName $inputHeaderType] xns] if {$firstHeader} { $env appendChild [$doc createElement "SOAP-ENV:Header" header] set firstHeader 0 } $header appendChild [$doc createElement $xns:$inputHeaderType headerData] ::WS::Utils::convertDictToEncodedType Client $serviceName $doc $headerData $argList $inputHeaderType } $env appendChild [$doc createElement "SOAP-ENV:Body" bod] set baseName [dict get $serviceInfo operation $operationName name] set callXns [dict get $serviceInfo operation $operationName xns] # side effect: node handle is saved in variable reply if {![string is space $callXns]} { $bod appendChild [$doc createElement $callXns:$baseName reply] } else { $bod appendChild [$doc createElement $baseName reply] } $reply setAttribute \ SOAP-ENV:encodingStyle "http://schemas.xmlsoap.org/soap/encoding/" |
︙ | ︙ | |||
2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 | # Maintenance History - as this file is modified, please be sure that you # update this segment of the file header block by # adding a complete entry at the bottom of the list. # # Version Date Programmer Comments / Changes / Reasons # ------- ---------- ---------- ------------------------------------------- # 1 08/06/2006 G.Lester Initial version # # ########################################################################### proc ::WS::Client::parseBinding {wsdlNode serviceName bindingName serviceInfoVar} { ::log:::log debug "Entering [info level 0]" upvar 1 $serviceInfoVar serviceInfo variable options set bindQuery [format {w:binding[attribute::name='%s']} $bindingName] array set msgToOper {} foreach binding [$wsdlNode selectNodes $bindQuery] { array unset msgToOper * set portName [lindex [split [$binding getAttribute type] {:}] end] ::log:::log debug "\t Processing binding '$bindingName' on port '$portName'" set operList [$binding selectNodes w:operation] set styleNode [$binding selectNodes d:binding] if {![info exists style]} { if {[catch {$styleNode getAttribute style} tmpStyle]} { set styleNode [$binding selectNodes {w:operation[1]/d:operation}] | > > | | | | | 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 | # Maintenance History - as this file is modified, please be sure that you # update this segment of the file header block by # adding a complete entry at the bottom of the list. # # Version Date Programmer Comments / Changes / Reasons # ------- ---------- ---------- ------------------------------------------- # 1 08/06/2006 G.Lester Initial version # 2.4.2 2017-08-31 H.Oehlmann Also set serviceArr operation members # inputsName and outputsName. # # ########################################################################### proc ::WS::Client::parseBinding {wsdlNode serviceName bindingName serviceInfoVar} { ::log:::log debug "Entering [info level 0]" upvar 1 $serviceInfoVar serviceInfo variable options set bindQuery [format {w:binding[attribute::name='%s']} $bindingName] array set msgToOper {} foreach binding [$wsdlNode selectNodes $bindQuery] { array unset msgToOper * set portName [lindex [split [$binding getAttribute type] {:}] end] ::log:::log debug "\t Processing binding '$bindingName' on port '$portName'" set operList [$binding selectNodes w:operation] set styleNode [$binding selectNodes d:binding] if {![info exists style]} { if {[catch {$styleNode getAttribute style} tmpStyle]} { set styleNode [$binding selectNodes {w:operation[1]/d:operation}] if {$styleNode eq {}} { ## ## This binding is for a SOAP level other than 1.1 ## ::log:::log debug "Skiping non-SOAP 1.1 binding [$binding asXML]" continue } set style [$styleNode getAttribute style] #puts "Using style for first operation {$style}" } else { set style $tmpStyle #puts "Using style for first binding {$style}" } if {!($style eq {document} || $style eq {rpc} )} { ::log:::log debug "Leaving [lindex [info level 0] 0] with error @1" return \ -code error \ -errorcode [list WS CLIENT UNSSTY $style] \ "Unsupported calling style: '$style'" } if {![info exists use]} { set use [[$binding selectNodes {w:operation[1]/w:input/d:body}] getAttribute use] if {!($style eq {document} && $use eq {literal} ) && !($style eq {rpc} && $use eq {encoded} )} { ::log:::log debug "Leaving [lindex [info level 0] 0] with error @2" return \ -code error \ -errorcode [list WS CLIENT UNSMODE $use] \ "Unsupported mode: $style/$use" } } |
︙ | ︙ | |||
2782 2783 2784 2785 2786 2787 2788 | } if {[dict exists $serviceInfo operation $operName]} { if {!$options(allowOperOverloading)} { return -code error \ -errorcode [list WS CLIENT NOOVERLOAD $operName] } ## | | > | | | | | 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 | } if {[dict exists $serviceInfo operation $operName]} { if {!$options(allowOperOverloading)} { return -code error \ -errorcode [list WS CLIENT NOOVERLOAD $operName] } ## ## See if the existing operation needs to be cloned ## set origType [lindex [split [dict get $serviceInfo operation $operName inputs] {:}] end] set newName ${operName}_${origType} if {![dict exists $serviceInfo operation $newName]} { ## ## Clone it ## dict set serviceInfo operation $baseName cloned 1 dict lappend serviceInfo operList $newName dict set serviceInfo operation $newName [dict get $serviceInfo operation $operName] } # typNameList contains inType inName outType outName set typeNameList [getTypesForPort $wsdlNode $serviceName $baseName $portName $inName serviceInfo $style] set operName ${operName}_[lindex [split [lindex $typeNameList 0] {:}] end] set cloneList [dict get $serviceInfo operation $baseName cloneList] lappend cloneList $operName dict set serviceInfo operation $baseName cloneList $cloneList dict set serviceInfo operation $operName isClone 1 } else { set typeNameList [getTypesForPort $wsdlNode $serviceName $baseName $portName $inName serviceInfo $style] dict set serviceInfo operation $operName isClone 0 } #puts "Processing operation $operName" set actionNode [$oper selectNodes d:operation] if {$actionNode eq {}} { ::log:::log debug "Skiping operation with no action [$oper asXML]" continue } dict lappend serviceInfo operList $operName dict set serviceInfo operation $operName cloneList {} dict set serviceInfo operation $operName cloned 0 dict set serviceInfo operation $operName name $baseName |
︙ | ︙ | |||
2835 2836 2837 2838 2839 2840 2841 | ## ## Get the input headers, if any ## set soapRequestHeaderList {{}} foreach inHeader [$oper selectNodes w:input/d:header] { ##set part [$inHeader getAttribute part] set tmp [$inHeader getAttribute use] | | | 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 | ## ## Get the input headers, if any ## set soapRequestHeaderList {{}} foreach inHeader [$oper selectNodes w:input/d:header] { ##set part [$inHeader getAttribute part] set tmp [$inHeader getAttribute use] if {$tmp ne $use} { ::log:::log debug "Leaving [lindex [info level 0] 0] with error @3" return \ -code error \ -errorcode [list WS CLIENT MIXUSE $use $tmp] \ "Mixed usageage not supported!'" } set msgName [$inHeader getAttribute message] |
︙ | ︙ | |||
2859 2860 2861 2862 2863 2864 2865 | ## ## Get the output header, if one ## set soapReplyHeaderList {{}} foreach outHeader [$oper selectNodes w:output/d:header] { ##set part [$outHeader getAttribute part] set tmp [$outHeader getAttribute use] | | | | < | | > > | | 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 | ## ## Get the output header, if one ## set soapReplyHeaderList {{}} foreach outHeader [$oper selectNodes w:output/d:header] { ##set part [$outHeader getAttribute part] set tmp [$outHeader getAttribute use] if {$tmp ne $use} { ::log:::log debug "Leaving [lindex [info level 0] 0] with error @4" return \ -code error \ -errorcode [list WS CLIENT MIXUSE $use $tmp] \ "Mixed usageage not supported!'" } set messagePath [$outHeader getAttribute message] set msgName [lindex [split $messagePath {:}] end] ::log:::log debug [list messageToType $wsdlNode $serviceName $baseName $msgName serviceInfo $style] set type [messageToType $wsdlNode $serviceName $baseName $msgName serviceInfo $style] lappend soapReplyHeaderList $type } dict set serviceInfo operation $operName soapReplyHeader $soapReplyHeaderList ## ## Validate that the input and output uses are the same ## set inUse $use set outUse $use catch {set inUse [[$oper selectNodes w:input/d:body] getAttribute use]} catch {set outUse [[$oper selectNodes w:output/d:body] getAttribute use]} foreach tmp [list $inUse $outUse] { if {$tmp ne $use} { ::log:::log debug "Leaving [lindex [info level 0] 0] with error @5" return \ -code error \ -errorcode [list WS CLIENT MIXUSE $use $tmp] \ "Mixed usageage not supported!'" } } ::log:::log debug "\t Input/Output types and names are {$typeNameList}" foreach {type name} $typeNameList mode {inputs outputs} { dict set serviceInfo operation $operName $mode $type # also set outputsname which is used to match it as alternate response node name dict set serviceInfo operation $operName ${mode}name $name } set inMessage [dict get $serviceInfo operation $operName inputs] if {[dict exists $serviceInfo inputMessages $inMessage] } { set operList [dict get $serviceInfo inputMessages $inMessage] } else { set operList {} } lappend operList $operName dict set serviceInfo inputMessages $inMessage $operList ## ## Handle target namespace defined at WSDL level for older RPC/Encoded ## if {![dict exists $serviceInfo targetNamespace]} { catch { |
︙ | ︙ | |||
2942 2943 2944 2945 2946 2947 2948 | # operNode - The DOM node for the operation. # portName - The name of the port. # inName - The name of the input message. # serviceInfoVar - The name of the dictionary containing the partially # parsed service. # style - style of call # | | > > > > > | | | > > | | > | | > | > > > > > > > | | < < < < < | | | 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 | # operNode - The DOM node for the operation. # portName - The name of the port. # inName - The name of the input message. # serviceInfoVar - The name of the dictionary containing the partially # parsed service. # style - style of call # # Returns : A list containing the input and output types and names # # Side-Effects : Defines Client mode types for the service as specified by the WSDL # # Exception Conditions : None # # Pre-requisite Conditions : None # # Original Author : Gerald W. Lester # #>>END PRIVATE<< # # Maintenance History - as this file is modified, please be sure that you # update this segment of the file header block by # adding a complete entry at the bottom of the list. # # Version Date Programmer Comments / Changes / Reasons # ------- ---------- ---------- ------------------------------------------- # 1 08/06/2006 G.Lester Initial version # 2.4.2 2017-08-31 H.Oehlmann Extend return by names to verify this # as return output node name. # 2.4.3 2017-11-03 H.Oehlmann If name is not given, set the default # name of <OP>Request/Response given by the # WSDL 1.0 standard. # # ########################################################################### proc ::WS::Client::getTypesForPort {wsdlNode serviceName operName portName inName serviceInfoVar style} { ::log:::log debug "Enteringing [info level 0]" upvar 1 $serviceInfoVar serviceInfo set inType {} set outType {} #set portQuery [format {w:portType[attribute::name='%s']} $portName] #set portNode [lindex [$wsdlNode selectNodes $portQuery] 0] if {$inName eq {}} { set operQuery [format {w:portType[attribute::name='%s']/w:operation[attribute::name='%s']} \ $portName $operName] } else { set operQuery [format {w:portType[attribute::name='%s']/w:operation[attribute::name='%s']/w:input[attribute::name='%s']/parent::*} \ $portName $operName $inName] } ::log:::log debug "\t operNode query is {$operQuery}" set operNode [$wsdlNode selectNodes $operQuery] if {$operNode eq {} && $inName ne {}} { set operQuery [format {w:portType[attribute::name='%s']/w:operation[attribute::name='%s']} \ $portName $operName] ::log:::log debug "\t operNode query is {$operQuery}" set operNode [$wsdlNode selectNodes $operQuery] } set resList {} foreach sel {w:input w:output} defaultNameSuffix {Request Response} { set nodeList [$operNode selectNodes $sel] if {1 == [llength $nodeList]} { set nodeCur [lindex $nodeList 0] set msgPath [$nodeCur getAttribute message] set msgCur [lindex [split $msgPath {:}] end] # Append type lappend resList [messageToType $wsdlNode $serviceName $operName $msgCur serviceInfo $style] # Append name if {[$nodeCur hasAttribute name]} { lappend resList [$nodeCur getAttribute name] } else { # Build the default name according WSDL 1.0 as # <Operation>Request/Response lappend resList ${operName}$defaultNameSuffix } } } ## ## Return the types ## ::log:::log debug "Leaving [lindex [info level 0] 0] with $resList" return $resList } ########################################################################### # # Private Procedure Header - as this procedure is modified, please be sure # that you update this header block. Thanks. # |
︙ | ︙ | |||
3060 3061 3062 3063 3064 3065 3066 | upvar 1 $serviceInfoVar serviceInfo ::log:::log debug "Enteringing [info level 0]" #puts "Message to Type $serviceName $operName $msgName" set msgQuery [format {w:message[attribute::name='%s']} $msgName] set msg [$wsdlNode selectNodes $msgQuery] | | | | 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 | upvar 1 $serviceInfoVar serviceInfo ::log:::log debug "Enteringing [info level 0]" #puts "Message to Type $serviceName $operName $msgName" set msgQuery [format {w:message[attribute::name='%s']} $msgName] set msg [$wsdlNode selectNodes $msgQuery] if {$msg eq {} && [llength [set msgNameList [split $msgName {:}]]] > 1} { set tmpMsgName [join [lrange $msgNameList 1 end] {:}] set msgQuery [format {w:message[attribute::name='%s']} $tmpMsgName] set msg [$wsdlNode selectNodes $msgQuery] } if {$msg eq {}} { return \ -code error \ -errorcode [list WS CLIENT BADMSGSEC $msgName] \ "Can not find message '$msgName'" } switch -exact -- $style { document/literal { |
︙ | ︙ | |||
3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 | # Maintenance History - as this file is modified, please be sure that you # update this segment of the file header block by # adding a complete entry at the bottom of the list. # # Version Date Programmer Comments / Changes / Reasons # ------- ---------- ---------- ------------------------------------------- # 1 07/06/2006 G.Lester Initial version # # ########################################################################### proc ::WS::Client::DoRawRestCall {serviceName objectName operationName argList {headers {}} {location {}}} { variable serviceArr ::log::log debug "Entering [info level 0]" | > > > | 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 | # Maintenance History - as this file is modified, please be sure that you # update this segment of the file header block by # adding a complete entry at the bottom of the list. # # Version Date Programmer Comments / Changes / Reasons # ------- ---------- ---------- ------------------------------------------- # 1 07/06/2006 G.Lester Initial version # 2.4.1 2017-08-31 H.Oehlmann Use utility function # ::WS::Utils::geturl_fetchbody for http call # which also follows redirects. # # ########################################################################### proc ::WS::Client::DoRawRestCall {serviceName objectName operationName argList {headers {}} {location {}}} { variable serviceArr ::log::log debug "Entering [info level 0]" |
︙ | ︙ | |||
3207 3208 3209 3210 3211 3212 3213 | } if {![dict exists $serviceInfo object $objectName operation $operationName]} { return \ -code error \ -errorcode [list WS CLIENT UNKOPER [list $serviceName $objectName $operationName]] \ "Unknown operation '$operationName' for object '$objectName' of service '$serviceName'" } | > > > > > | < < < < < < | < < | | | < < < < < > < < > | < < < < < < < < | | < | 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 | } if {![dict exists $serviceInfo object $objectName operation $operationName]} { return \ -code error \ -errorcode [list WS CLIENT UNKOPER [list $serviceName $objectName $operationName]] \ "Unknown operation '$operationName' for object '$objectName' of service '$serviceName'" } ## ## build call query ## if {$location ne {}} { set url $location } else { set url [dict get $serviceInfo object $objectName location] } SaveAndSetOptions $serviceName if {[catch {set query [buildRestCallquery $serviceName $objectName $operationName $url $argList]} err]} { RestoreSavedOptions $serviceName return -code error -errorcode $::errorCode -errorinfo $::errorInfo $err } else { RestoreSavedOptions $serviceName } if {[dict exists $serviceInfo headers]} { set headers [concat $headers [dict get $serviceInfo headers]] } ## ## do http call ## if {[llength $headers]} { set body [::WS::Utils::geturl_fetchbody $url -query $query -type [dict get $serviceInfo contentType] -headers $headers] } else { set body [::WS::Utils::geturl_fetchbody $url -query $query -type [dict get $serviceInfo contentType]] } ::log::log debug "Leaving ::WS::Client::DoRawRestCall with {$body}" return $body } ########################################################################### # # Public Procedure Header - as this procedure is modified, please be sure # that you update this header block. Thanks. |
︙ | ︙ | |||
3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 | # Maintenance History - as this file is modified, please be sure that you # update this segment of the file header block by # adding a complete entry at the bottom of the list. # # Version Date Programmer Comments / Changes / Reasons # ------- ---------- ---------- ------------------------------------------- # 1 07/06/2006 G.Lester Initial version # # ########################################################################### proc ::WS::Client::DoRestCall {serviceName objectName operationName argList {headers {}} {location {}}} { variable serviceArr ::log::log debug "Entering [info level 0]" | > > > | 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 | # Maintenance History - as this file is modified, please be sure that you # update this segment of the file header block by # adding a complete entry at the bottom of the list. # # Version Date Programmer Comments / Changes / Reasons # ------- ---------- ---------- ------------------------------------------- # 1 07/06/2006 G.Lester Initial version # 2.4.1 2017-08-31 H.Oehlmann Use utility function # ::WS::Utils::geturl_fetchbody for http call # which also follows redirects. # # ########################################################################### proc ::WS::Client::DoRestCall {serviceName objectName operationName argList {headers {}} {location {}}} { variable serviceArr ::log::log debug "Entering [info level 0]" |
︙ | ︙ | |||
3332 3333 3334 3335 3336 3337 3338 | } if {![dict exists $serviceInfo object $objectName operation $operationName]} { return \ -code error \ -errorcode [list WS CLIENT UNKOPER [list $serviceName $objectName $operationName]] \ "Unknown operation '$operationName' for object '$objectName' of service '$serviceName'" } | | > > > > > < > | | > > > > < | < | < | | < < < < < < < < < < < < | > | < < | | < < < < < < < < < < | < < > | < | | < | 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 | } if {![dict exists $serviceInfo object $objectName operation $operationName]} { return \ -code error \ -errorcode [list WS CLIENT UNKOPER [list $serviceName $objectName $operationName]] \ "Unknown operation '$operationName' for object '$objectName' of service '$serviceName'" } if {$location ne {}} { set url $location } else { set url [dict get $serviceInfo object $objectName location] } ## ## build call query ## SaveAndSetOptions $serviceName if {[catch {set query [buildRestCallquery $serviceName $objectName $operationName $url $argList]} err]} { RestoreSavedOptions $serviceName return -code error -errorcode $::errorCode -errorinfo $::errorInfo $err } RestoreSavedOptions $serviceName ## ## Do http call ## if {[dict exists $serviceInfo headers]} { set headers [concat $headers [dict get $serviceInfo headers]] } if {[llength $headers]} { set body [::WS::Utils::geturl_fetchbody $url -query $query -type [dict get $serviceInfo contentType] -headers $headers] } else { set body [::WS::Utils::geturl_fetchbody $url -query $query -type [dict get $serviceInfo contentType]] } ## ## Parse results ## SaveAndSetOptions $serviceName if {[catch { parseRestResults $serviceName $objectName $operationName $body } results]} { RestoreSavedOptions $serviceName ::log::log debug "Leaving (error) ::WS::Client::DoRestCall" return -code error $results } RestoreSavedOptions $serviceName ::log::log debug "Leaving ::WS::Client::DoRestCall with {$results}" return $results } ########################################################################### # # Public Procedure Header - as this procedure is modified, please be sure # that you update this header block. Thanks. |
︙ | ︙ | |||
3595 3596 3597 3598 3599 3600 3601 | set xml [format {<?xml version="1.0" encoding="%s"?>} $encoding] append xml "\n" [$doc asXML -indent none -doctypeDeclaration 0] #regsub "<!DOCTYPE\[^>\]*>\n" [::dom::DOMImplementation serialize $doc] {} xml $doc delete set xml [encoding convertto $encoding $xml] set inTransform [dict get $serviceInfo inTransform] | | | 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 | set xml [format {<?xml version="1.0" encoding="%s"?>} $encoding] append xml "\n" [$doc asXML -indent none -doctypeDeclaration 0] #regsub "<!DOCTYPE\[^>\]*>\n" [::dom::DOMImplementation serialize $doc] {} xml $doc delete set xml [encoding convertto $encoding $xml] set inTransform [dict get $serviceInfo inTransform] if {$inTransform ne {}} { set xml [$inTransform $serviceName $operationName REQUEST $xml $url $argList] } ::log::log debug "Leaving ::WS::Client::buildRestCallquery with {$xml}" return $xml |
︙ | ︙ | |||
3659 3660 3661 3662 3663 3664 3665 | ::log::log debug "In parseResults $serviceName $operationName {$inXML}" set first [string first {<} $inXML] if {$first > 0} { set inXML [string range $inXML $first end] } set serviceInfo $serviceArr($serviceName) set outTransform [dict get $serviceInfo outTransform] | | > > | | | | 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 | ::log::log debug "In parseResults $serviceName $operationName {$inXML}" set first [string first {<} $inXML] if {$first > 0} { set inXML [string range $inXML $first end] } set serviceInfo $serviceArr($serviceName) set outTransform [dict get $serviceInfo outTransform] if {$outTransform ne {}} { set inXML [$outTransform $serviceName $operationName REPLY $inXML] } set expectedMsgType [dict get $serviceInfo object $objectName operation $operationName outputs] # save parsed xml handle in variable doc dom parse $inXML doc # save top node handle in variable top $doc documentElement top set xns {} foreach tmp [dict get $serviceInfo targetNamespace] { lappend xns $tmp } ::log::log debug "Using namespaces {$xns}" set body $top set status [$body getAttribute status] ## ## See if it is a standard error packet ## if {$status ne {ok}} { set faultstring {} if {[catch {set faultstring [[$body selectNodes error] asText]}]} { catch {set faultstring [[$body selectNodes error] asText]} } $doc delete return \ -code error \ -errorcode [list WS CLIENT REMERR $status] \ -errorinfo {} \ $faultstring } ## ## Convert the packet to a dictionary ## set results {} set options [::WS::Utils::SetOption] ::WS::Utils::SetOption UseNS 0 ::WS::Utils::SetOption parseInAttr 1 ::log::log debug "Calling [list ::WS::Utils::convertTypeToDict Client $serviceName $body $expectedMsgType $body]" if {$expectedMsgType ne {}} { set node [$body childNodes] set nodeName [$node nodeName] if {$objectName ne $nodeName} { return \ -code error \ -errorcode [list WS CLIENT BADRESPONSE [list $objectName $nodeName]] \ -errorinfo {} \ "Unexpected message type {$nodeName}, expected {$objectName}" } set results [::WS::Utils::convertTypeToDict \ |
︙ | ︙ | |||
3770 3771 3772 3773 3774 3775 3776 | ::log::log debug "Entering ::WS::Client::asyncCallDone {$serviceName $objectName $operationName $succesCmd $errorCmd $token}" ## ## Check for errors ## set body [::http::data $token] ::log::log info "\nReceived: $body" | | | | 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 | ::log::log debug "Entering ::WS::Client::asyncCallDone {$serviceName $objectName $operationName $succesCmd $errorCmd $token}" ## ## Check for errors ## set body [::http::data $token] ::log::log info "\nReceived: $body" if {[::http::status $token] ne {ok} || ( [::http::ncode $token] != 200 && $body eq {} )} { set errorCode [list WS CLIENT HTTPERROR [::http::code $token]] set hadError 1 set errorInfo [FormatHTTPError $token] } else { SaveAndSetOptions $serviceName if {[catch {set hadError [catch {parseRestResults $serviceName $objectName $operationName $body} results]} err]} { RestoreSavedOptions $serviceName |
︙ | ︙ |
Changes to Embedded.tcl.
︙ | ︙ | |||
40 41 42 43 44 45 46 | } package require uri package require base64 package require html package require log | | | 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | } package require uri package require base64 package require html package require log package provide WS::Embeded 2.4.0 namespace eval ::WS::Embeded { array set portInfo {} set portList [list] set forever {} |
︙ | ︙ |
Changes to ServerSide.tcl.
︙ | ︙ | |||
35 36 37 38 39 40 41 | ## LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ## ## ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ## ## POSSIBILITY OF SUCH DAMAGE. ## ## ## ############################################################################### package require Tcl 8.4 | | | | 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | ## LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ## ## ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ## ## POSSIBILITY OF SUCH DAMAGE. ## ## ## ############################################################################### package require Tcl 8.4 package require WS::Utils 2.4 ; # provides dict package require html package require log package require tdom package provide WS::Server 2.4.0 namespace eval ::WS::Server { array set ::WS::Server::serviceArr {} set ::WS::Server::procInfo {} set ::WS::Server::mode {} } |
︙ | ︙ | |||
124 125 126 127 128 129 130 131 132 133 134 135 136 137 | # -prefix - Path prefix used for the namespace and endpoint # Defaults to "/service/" plus the service name # -traceEnabled - Boolean to enable/disable trace being passed back in exception # Defaults to "Y" # -docFormat - Format of the documentation for operations ("text" or "html"). # Defaults to "text" # -stylesheet - The CSS stylesheet URL used in the HTML documentation # # # Returns : Nothing # # Side-Effects : None # # Exception Conditions : | > > > > > > | 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | # -prefix - Path prefix used for the namespace and endpoint # Defaults to "/service/" plus the service name # -traceEnabled - Boolean to enable/disable trace being passed back in exception # Defaults to "Y" # -docFormat - Format of the documentation for operations ("text" or "html"). # Defaults to "text" # -stylesheet - The CSS stylesheet URL used in the HTML documentation # -errorCallback - Callback to be invoked in the event of an error being produced # -verifyUserArgs - Boolean to enable/disable validating user supplied arguments # Defaults to "N" # -enforceRequired - Throw an error if a required field is not included in the # response. # Defaults to "N" # # # Returns : Nothing # # Side-Effects : None # # Exception Conditions : |
︙ | ︙ | |||
171 172 173 174 175 176 177 178 179 180 181 182 183 184 | -author {} -description {} -mode {tclhttpd} -ports {80} -traceEnabled {Y} -docFormat {text} -stylesheet {} } array set defaults $args if {[string equal $defaults(-mode) channel]} { set defaults(-ports) {stdin stdout} array set defaults $args } set requiredList {-service} | > > > > | 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | -author {} -description {} -mode {tclhttpd} -ports {80} -traceEnabled {Y} -docFormat {text} -stylesheet {} -beautifyJson {N} -errorCallback {} -verifyUserArgs {N} -enforceRequired {N} } array set defaults $args if {[string equal $defaults(-mode) channel]} { set defaults(-ports) {stdin stdout} array set defaults $args } set requiredList {-service} |
︙ | ︙ | |||
196 197 198 199 200 201 202 | } set service $defaults(-service) if {![info exists defaults(-prefix)]} { set defaults(-prefix) /service/$service } # find default host if {![info exists defaults(-host)]} { | | | | | | | | | | | | | 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 | } set service $defaults(-service) if {![info exists defaults(-prefix)]} { set defaults(-prefix) /service/$service } # find default host if {![info exists defaults(-host)]} { switch -exact -- $defaults(-mode) { embedded { set me [socket -server garbage_word -myaddr [info hostname] 0] set defaults(-host) [lindex [fconfigure $me -sockname] 0] close $me if {0 !=[llength $defaults(-ports)] && 80 != [lindex $defaults(-ports) 0]} { append defaults(-host) ":[lindex $defaults(-ports) 0]" } } default { set defaults(-host) localhost } } } set defaults(-uri) $service namespace eval ::$service {} set serviceArr($service) [array get defaults] if {![dict exists $procInfo $service operationList]} { dict set procInfo $service operationList {} |
︙ | ︙ | |||
240 241 242 243 244 245 246 | ::Url_PrefixInstall $defaults(-prefix) ::WS::Server::generateInfo_${service} \ -thread 0 } wub { package require WS::Wub } aolserver { | | | 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | ::Url_PrefixInstall $defaults(-prefix) ::WS::Server::generateInfo_${service} \ -thread 0 } wub { package require WS::Wub } aolserver { package require WS::AOLserver } rivet { package require Rivet } wibble { ## ## Define zone handler - get code from andy |
︙ | ︙ | |||
726 727 728 729 730 731 732 | ::WS::Channel::ReturnData \ $sock \ "text/xml; charset=UTF-8" \ "<html><head><title>Webservice Error</title></head><body><h2>$msg</h2></body></html>" \ 404 } rivet { | | | | 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 | ::WS::Channel::ReturnData \ $sock \ "text/xml; charset=UTF-8" \ "<html><head><title>Webservice Error</title></head><body><h2>$msg</h2></body></html>" \ 404 } rivet { headers type "text/html; charset=UTF-8" headers numeric 404 puts "<html><head><title>Webservice Error</title></head><body><h2>$msg</h2></body></html>" } aolserver { ::WS::AOLserver::ReturnData \ $sock \ text/html \ "<html><head><title>Webservice Error</title></head><body><h2>$msg</h2></body></html>" \ 404 } wibble { |
︙ | ︙ | |||
771 772 773 774 775 776 777 | } embedded { set xml [GetWsdl $serviceName] ::WS::Embeded::ReturnData $sock "text/xml; charset=UTF-8" $xml 200 } rivet { set xml [GetWsdl $serviceName] | | | 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 | } embedded { set xml [GetWsdl $serviceName] ::WS::Embeded::ReturnData $sock "text/xml; charset=UTF-8" $xml 200 } rivet { set xml [GetWsdl $serviceName] headers type "text/xml; charset=UTF-8" headers numeric 200 puts $xml } aolserver { set xml [GetWsdl $serviceName] ::WS::AOLserver::ReturnData $sock text/xml $xml 200 } |
︙ | ︙ | |||
838 839 840 841 842 843 844 845 846 847 848 849 850 851 | variable serviceArr array set serviceData $serviceArr($serviceName) set targetNamespace "http://$serviceData(-host)$serviceData(-prefix)" return [::WS::Utils::GenerateScheme $mode $serviceName $doc $parent $targetNamespace] } ########################################################################### # # Private Procedure Header - as this procedure is modified, please be sure # that you update this header block. Thanks. # #>>BEGIN PRIVATE<< | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 | variable serviceArr array set serviceData $serviceArr($serviceName) set targetNamespace "http://$serviceData(-host)$serviceData(-prefix)" return [::WS::Utils::GenerateScheme $mode $serviceName $doc $parent $targetNamespace] } ########################################################################### # # Private Procedure Header - as this procedure is modified, please be sure # that you update this header block. Thanks. # #>>BEGIN PRIVATE<< # # Procedure Name : ::WS::Server::generateJsonInfo # # Description : Generate an json description of the service, the operations # and all applicable type definitions. # # Arguments : # serviceName - The name of the service # sock - The socket to return the WSDL on # args - not used # # Returns : # 1 - On error # 0 - On success # # Side-Effects : None # # Exception Conditions : None # # Pre-requisite Conditions : None # # Original Author : James Sulak # #>>END PRIVATE<< # # Maintenance History - as this file is modified, please be sure that you # update this segment of the file header block by # adding a complete entry at the bottom of the list. # # Version Date Programmer Comments / Changes / Reasons # ------- ---------- ---------- ------------------------------------------- # 1 05/16/2012 J.Sulak Initial version # # ########################################################################### # NOTE: This proc only works with Rivet # TODO: Update to handle jsonp? proc ::WS::Server::generateJsonInfo { service sock args } { variable serviceArr variable procInfo ::log::log debug "Generating JSON Documentation for $service on $sock with {$args}" set serviceInfo $serviceArr($service) array set serviceData $serviceInfo set doc [yajl create #auto -beautify $serviceData(-beautifyJson)] $doc map_open $doc string operations array_open ::log::log debug "\tDisplay Operations (json)" foreach oper [lsort -dictionary [dict get $procInfo $service operationList]] { $doc map_open # operation name $doc string name string $oper # description set description [dict get $procInfo $service op$oper docs] $doc string description string $description # parameters if {[llength [dict get $procInfo $service op$oper argOrder]]} { $doc string inputs array_open foreach arg [dict get $procInfo $service op$oper argOrder] { ::log::log debug "\t\t\tDisplaying '$arg'" if {[dict exists $procInfo $service op$oper argList $arg comment]} { set comment [dict get $procInfo $service op$oper argList $arg comment] } else { set comment {} } set type [dict get $procInfo $service op$oper argList $arg type] $doc map_open string name string $arg string type string $type string comment string $comment map_close } $doc array_close } else { $doc string inputs array_open array_close } $doc string returns map_open if {[dict exists $procInfo $service op$oper returnInfo comment]} { set comment [dict get $procInfo $service op$oper returnInfo comment] } else { set comment {} } set type [dict get $procInfo $service op$oper returnInfo type] $doc string comment string $comment string type string $type $doc map_close $doc map_close } $doc array_close ::log::log debug "\tDisplay custom types" $doc string types array_open set localTypeInfo [::WS::Utils::GetServiceTypeDef Server $service] foreach type [lsort -dictionary [dict keys $localTypeInfo]] { ::log::log debug "\t\tDisplaying '$type'" $doc map_open $doc string name string $type $doc string fields array_open set typeDetails [dict get $localTypeInfo $type definition] foreach part [lsort -dictionary [dict keys $typeDetails]] { ::log::log debug "\t\t\tDisplaying '$part'" set subType [dict get $typeDetails $part type] set comment {} if {[dict exists $typeDetails $part comment]} { set comment [dict get $typeDetails $part comment] } $doc map_open string field string $part string type string $subType string comment string $comment map_close } $doc array_close $doc map_close } $doc array_close $doc map_close set contentType "application/json; charset=UTF-8" headers type $contentType headers numeric 200 puts [$doc get] $doc delete } ########################################################################### # # Private Procedure Header - as this procedure is modified, please be sure # that you update this header block. Thanks. # #>>BEGIN PRIVATE<< |
︙ | ︙ | |||
987 988 989 990 991 992 993 | ::WS::Embeded::ReturnData $sock "text/html; charset=UTF-8" $msg 200 } channel { ::WS::Channel::ReturnData $sock "text/html; charset=UTF-8" $msg 200 } rivet { headers numeric 200 | | | 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 | ::WS::Embeded::ReturnData $sock "text/html; charset=UTF-8" $msg 200 } channel { ::WS::Channel::ReturnData $sock "text/html; charset=UTF-8" $msg 200 } rivet { headers numeric 200 headers type "text/html; charset=UTF-8" puts $msg } aolserver { ::WS::AOLserver::ReturnData $sock text/html $msg 200 } wibble { upvar 1 [lindex $args 0] responseDict |
︙ | ︙ | |||
1042 1043 1044 1045 1046 1047 1048 | # Version Date Programmer Comments / Changes / Reasons # ------- ---------- ---------- ------------------------------------------- # 1 07/06/2006 G.Lester Initial version # # ########################################################################### proc ::WS::Server::displayType {serviceName type} { | | | 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 | # Version Date Programmer Comments / Changes / Reasons # ------- ---------- ---------- ------------------------------------------- # 1 07/06/2006 G.Lester Initial version # # ########################################################################### proc ::WS::Server::displayType {serviceName type} { set testType [string trimright $type {()?}] if {([lindex [::WS::Utils::TypeInfo Server $serviceName $testType] 0] == 0) && ([info exists ::WS::Utils::simpleTypes($testType)])} { set result $type } else { set result [format {<a href="#type_%1$s">%2$s</a>} $testType $type] } return $result |
︙ | ︙ | |||
1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 | # Description : Process the call to an operation. If an error occurs, a standard # error packet is sent, otherwise the appropriate message type # is sent. # # Arguments : # serviceName - The name of the service # sock - The socket to return the WSDL on # args - not used # # Returns : # 1 - On error # 0 - On success # # Side-Effects : None | > | 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 | # Description : Process the call to an operation. If an error occurs, a standard # error packet is sent, otherwise the appropriate message type # is sent. # # Arguments : # serviceName - The name of the service # sock - The socket to return the WSDL on # -rest - Use Rest flavor call instead of SOAP # args - not used # # Returns : # 1 - On error # 0 - On success # # Side-Effects : None |
︙ | ︙ | |||
1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 | set inXML [dict get $requestDict post xml ""] } default { upvar #0 Httpd$sock data set inXML $data(query) } } ::log::log debug "In ::WS::Server::callOperation {$service $sock $args}" array set serviceInfo $serviceArr($service) ::log::log debug "\tDocument is {$inXML}" set ::errorInfo {} set ::errorCode {} set ns $service set inTransform $serviceInfo(-intransform) set outTransform $serviceInfo(-outtransform) | > > > > > > < < < < | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | | | | | | | | < < | < | | | | | | | | | | | | | | | | | | > | > > > > > | | > > > | > > > > > > | | | | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < | < | | | < | < | | | | | | | < | < > | | | < | < | | | | | | | | | | | | | | > > > > > > | | > > > | > > > > > > | | | | | | | | | 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 | set inXML [dict get $requestDict post xml ""] } default { upvar #0 Httpd$sock data set inXML $data(query) } } # decide if SOAP or REST mode should be used. set flavor "soap" if {[lsearch -exact $args "-rest"] != -1} { set flavor "rest" } ::log::log debug "In ::WS::Server::callOperation {$service $sock $args}" array set serviceInfo $serviceArr($service) ::log::log debug "\tDocument is {$inXML}" set ::errorInfo {} set ::errorCode {} set ns $service set inTransform $serviceInfo(-intransform) set outTransform $serviceInfo(-outtransform) if {$inTransform ne {}} { set inXML [$inTransform REQUEST $inXML] } # Get a reference to the error callback set errorCallback $serviceInfo(-errorCallback) ## ## Parse the input and determine the name of the method being invoked. ## switch -exact -- $flavor { rest { package require yajltcl ; # only needed for rest, not soap. set operation [lindex $inXML 0] set contentType "application/json" set doc "" array set rawargs [lindex $inXML 1] if {[info exists rawargs(jsonp_callback)]} { if {![regexp {^[a-zA-Z_0-9]+$} $rawargs(jsonp_callback)]} { # sanitize the JSONP callback function name for security. set rawargs(jsonp_callback) FlightXmlCallback } set contentType "text/javascript" } } soap { # skip any XML header set first [string first {<} $inXML] if {$first > 0} { set inXML [string range $inXML $first end] } # parse the XML request dom parse $inXML doc $doc documentElement top ::log::log debug [list $doc selectNodesNamespaces \ [list ENV http://schemas.xmlsoap.org/soap/envelope/ \ $service http://$serviceInfo(-host)$serviceInfo(-prefix)]] $doc selectNodesNamespaces \ [list ENV http://schemas.xmlsoap.org/soap/envelope/ \ $service http://$serviceInfo(-host)$serviceInfo(-prefix)] $doc documentElement rootNode # extract the name of the method set top [$rootNode selectNodes /ENV:Envelope/ENV:Body/*] catch {$top localName} requestMessage set legacyRpcMode 0 if {$requestMessage == ""} { # older RPC/Encoded clients need to try nodeName instead. # Python pySoap needs this. catch {$top nodeName} requestMessage set legacyRpcMode 1 } ::log::log debug "requestMessage = {$requestMessage}" if {[string match {*Request} $requestMessage]} { set operation [string range $requestMessage 0 end-7] } else { # broken clients might not have sent the correct Document Wrapped name. # Python pySoap and Perl SOAP::Lite need this. set operation $requestMessage set legacyRpcMode 1 } set contentType "text/xml" } default { if {$errorCallback ne {}} { $errorCallback "BAD_FLAVOR No supported protocol" {} "UnknownMethod" $flavor } error "bad flavor" } } ## ## Check that the method exists. ## if {![dict exists $procInfo $service op$operation argList]} { set msg "Method $operation not found" ::log::log error $msg set ::errorInfo {} set ::errorCode [list Server UNKNOWN_METHOD $operation] set response [generateError \ $serviceInfo(-traceEnabled) \ CLIENT \ $msg \ [list "errorCode" $::errorCode "stackTrace" $::errorInfo] \ $flavor] catch {$doc delete} set httpStatus 404 if {$errorCallback ne {}} { $errorCallback "UNKNOWN_METHOD $msg" httpStatus $operation $flavor } ::log::log debug "Leaving @ error 1::WS::Server::callOperation $response" # wrap in JSONP if {$flavor == "rest" && [info exists rawargs(jsonp_callback)]} { set response "$rawargs(jsonp_callback)($response)" } switch -exact -- $mode { tclhttpd { ::Httpd_ReturnData $sock "$contentType; charset=UTF-8" $response $httpStatus } embedded { ::WS::Embeded::ReturnData $sock "$contentType; charset=UTF-8" $response $httpStatus } rivet { headers type "$contentType; charset=UTF-8" headers numeric $httpStatus puts $response } aolserver { ::WS::AOLserver::ReturnData $sock "$contentType; charset=UTF-8" $response $httpStatus } wibble { ::WS::Wibble::ReturnData responseDict "$contentType; charset=UTF-8" $response $httpStatus } default { ## Do nothing } } return; } set baseName $operation set cmdName op$baseName set methodName "${ns}::$baseName" ## ## Parse the arguments for the method. ## set argInfo [dict get $procInfo $ns $cmdName argList] if {[catch { # Check that all supplied arguments are valid set methodArgs [dict get $procInfo $ns $cmdName argOrder] if {$serviceInfo(-verifyUserArgs)} { foreach {key value} [array get rawargs] { if {[lsearch -exact $methodArgs $key] == -1} { error "Invalid argument '$key' supplied" } } } switch -exact -- $flavor { rest { set tclArgList {} foreach argName $methodArgs { set argType [string trim [dict get $argInfo $argName type]] set typeInfoList [::WS::Utils::TypeInfo Server $service $argType] if {![info exists rawargs($argName)]} { ::log::log debug "did not find argument for $argName, leaving blank" lappend tclArgList {} continue } switch -exact -- $typeInfoList { {0 0} { ## Simple non-array lappend tclArgList $rawargs($argName) } {0 1} { ## Simple array lappend tclArgList $rawargs($argName) } {1 0} { ## Non-simple non-array error "TODO JSON" #lappend tclArgList [::WS::Utils::convertTypeToDict Server $service $node $argType $top] } {1 1} { ## Non-simple array error "TODO JSON" #set tmp {} #set argType [string trimright $argType {()?}] #foreach row $node { # lappend tmp [::WS::Utils::convertTypeToDict Server $service $row $argType $top] #} #lappend tclArgList $tmp } default { ## Do nothing } } } } soap { foreach pass [list 1 2 3] { set tclArgList {} set gotAnyArgs 0 set argIndex 0 foreach argName $methodArgs { set argType [string trim [dict get $argInfo $argName type]] set typeInfoList [::WS::Utils::TypeInfo Server $service $argType] if {$pass == 1} { # access arguments by name using full namespace set path $service:$argName set node [$top selectNodes $path] } elseif {$pass == 2} { # legacyRpcMode only, access arguments by unqualified name set path $argName set node [$top selectNodes $path] } else { # legacyRpcMode only, access arguments by index set path "legacy argument index $argIndex" set node [lindex [$top childNodes] $argIndex] incr argIndex } if {[string equal $node {}]} { ::log::log debug "did not find argument for $argName using $path, leaving blank" lappend tclArgList {} continue } ::log::log debug "found argument $argName using $path, processing $node" set gotAnyArgs 1 switch -exact -- $typeInfoList { {0 0} { ## Simple non-array lappend tclArgList [$node asText] } {0 1} { ## Simple array set tmp {} foreach row $node { lappend tmp [$row asText] } lappend tclArgList $tmp } {1 0} { ## Non-simple non-array set argType [string trimright $argType {?}] lappend tclArgList [::WS::Utils::convertTypeToDict Server $service $node $argType $top] } {1 1} { ## Non-simple array set tmp {} set argType [string trimright $argType {()?}] foreach row $node { lappend tmp [::WS::Utils::convertTypeToDict Server $service $row $argType $top] } lappend tclArgList $tmp } default { ## Do nothing } } } ::log::log debug "gotAnyArgs $gotAnyArgs, legacyRpcMode $legacyRpcMode" if {$gotAnyArgs || !$legacyRpcMode} break } } default { if {$errorCallback ne {}} { $errorCallback "BAD_FLAVOR No supported protocol" {} $operation $flavor } error "invalid flavor" } } ::log::log debug "finalargs $tclArgList" } errMsg]} { ::log::log error $errMsg set localerrorCode $::errorCode set localerrorInfo $::errorInfo set response [generateError \ $serviceInfo(-traceEnabled) \ CLIENT \ "Error Parsing Arguments -- $errMsg" \ [list "errorCode" $localerrorCode "stackTrace" $localerrorInfo] \ $flavor] catch {$doc delete} set httpStatus 400 if {$errorCallback ne {}} { $errorCallback "INVALID_ARGUMENT $errMsg" httpStatus $operation $flavor } ::log::log debug "Leaving @ error 3::WS::Server::callOperation $response" # wrap in JSONP if {$flavor == "rest" && [info exists rawargs(jsonp_callback)]} { set response "$rawargs(jsonp_callback)($response)" } switch -exact -- $mode { tclhttpd { ::Httpd_ReturnData $sock "$contentType; charset=UTF-8" $response $httpStatus } embedded { ::WS::Embeded::ReturnData $sock "$contentType; charset=UTF-8" $response $httpStatus } channel { ::WS::Channel::ReturnData $sock "$contentType; charset=UTF-8" $response $httpStatus } rivet { headers type "$contentType; charset=UTF-8" headers numeric $httpStatus puts $response } aolserver { ::WS::AOLserver::ReturnData $sock "$contentType; charset=UTF-8" $response $httpStatus } wibble { ::WS::Wibble::ReturnData responseDict "$contentType; charset=UTF-8" $response $httpStatus } default { ## Do nothing } } return; } |
︙ | ︙ | |||
1371 1372 1373 1374 1375 1376 1377 | default { lappend cmd $ns $baseName $data(ipaddr) $data(headerlist) $headerList } } eval $cmd set results [eval \$methodName $tclArgList] # generate a reply packet | | > > > > > > > > | > > > < | | | | | | | | | | | > > > | > > > > > > | | | > > > > | | | | | | 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 | default { lappend cmd $ns $baseName $data(ipaddr) $data(headerlist) $headerList } } eval $cmd set results [eval \$methodName $tclArgList] # generate a reply packet set response [generateReply $ns $baseName $results $flavor] # wrap in JSONP if {$flavor == "rest" && [info exists rawargs(jsonp_callback)]} { set response "$rawargs(jsonp_callback)($response)" } # mangle the XML declaration if {$flavor == "soap"} { # regsub "<!DOCTYPE\[^>\]+>\n" $response {} response set response [string map {{<?xml version="1.0"?>} {<?xml version="1.0" encoding="utf-8"?>}} $response] } catch {$doc delete} if {![string equal $outTransform {}]} { set response [$outTransform REPLY $response $operation $results] } if {[info exists serviceInfo(-postmonitor)] && [string length $serviceInfo(-postmonitor)]} { set precmd $serviceInfo(-postmonitor) lappend precmd POST $service $operation OK $results catch $precmd } ::log::log debug "Leaving ::WS::Server::callOperation $response" switch -exact -- $mode { tclhttpd { ::Httpd_ReturnData $sock "$contentType; charset=UTF-8" $response 200 } embedded { ::WS::Embeded::ReturnData $sock "$contentType; charset=UTF-8" $response 200 } channel { ::WS::Channel::ReturnData $sock "$contentType; charset=UTF-8" $response 200 } rivet { headers type "$contentType; charset=UTF-8" headers numeric 200 puts $response } aolserver { ::WS::AOLserver::ReturnData $sock "$contentType; charset=UTF-8" $response 200 } wibble { ::WS::Wibble::ReturnData responseDict "$contentType; charset=UTF-8" $response 200 } default { ## Do nothing } } } msg]} { ## ## Handle errors ## set localerrorCode $::errorCode set localerrorInfo $::errorInfo if {[info exists serviceInfo(-postmonitor)] && [string length $serviceInfo(-postmonitor)]} { set precmd $serviceInfo(-postmonitor) lappend precmd POST $service $operation ERROR $msg catch $precmd } set response [generateError \ $serviceInfo(-traceEnabled) \ CLIENT \ $msg \ [list "errorCode" $localerrorCode "stackTrace" $localerrorInfo] \ $flavor] catch {$doc delete} set httpStatus 500 if {$errorCallback ne {}} { $errorCallback $msg httpStatus $operation $flavor } ::log::log debug "Leaving @ error 2::WS::Server::callOperation $response" # wrap in JSONP if {$flavor == "rest" && [info exists rawargs(jsonp_callback)]} { set response "$rawargs(jsonp_callback)($response)" } switch -exact -- $mode { tclhttpd { ::Httpd_ReturnData $sock "$contentType; charset=UTF-8" $response $httpStatus } embedded { ::WS::Embeded::ReturnData $sock "$contentType; charset=UTF-8" $response $httpStatus } channel { ::WS::Channel::ReturnData $sock "$contentType; charset=UTF-8" $response $httpStatus } rivet { if {[lindex $localerrorCode 0] == "RIVET" && [lindex $localerrorCode 1] == "ABORTPAGE"} { # if we caught an abort_page, then re-trigger it. abort_page } headers type "$contentType; charset=UTF-8" headers numeric $httpStatus puts $response } aolserver { ::WS::AOLserver::ReturnData $sock $contentType $response $httpStatus } wibble { ::WS::Wibble::ReturnData responseDict "$contentType; charset=UTF-8" $response $httpStatus } default { ## Do nothing } } return; } |
︙ | ︙ | |||
1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 | # Description : Generate a standard error packet # # Arguments : # includeTrace - Boolean indicate if the trace is to be included. # faultcode - The code describing the error # faultstring - The string describing the error. # detail - Optional details of error. # # Returns : XML formatted standard error packet # # Side-Effects : None # # Exception Conditions : None # | > | 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 | # Description : Generate a standard error packet # # Arguments : # includeTrace - Boolean indicate if the trace is to be included. # faultcode - The code describing the error # faultstring - The string describing the error. # detail - Optional details of error. # flavor - Output mode: "soap" or "rest" # # Returns : XML formatted standard error packet # # Side-Effects : None # # Exception Conditions : None # |
︙ | ︙ | |||
1498 1499 1500 1501 1502 1503 1504 | # # Version Date Programmer Comments / Changes / Reasons # ------- ---------- ---------- ------------------------------------------- # 1 07/06/2006 G.Lester Initial version # # ########################################################################### | | > > > > > > > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > > > > | | > | 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 | # # Version Date Programmer Comments / Changes / Reasons # ------- ---------- ---------- ------------------------------------------- # 1 07/06/2006 G.Lester Initial version # # ########################################################################### proc ::WS::Server::generateError {includeTrace faultcode faultstring detail flavor} { ::log::log debug "Entering ::WS::Server::generateError $faultcode $faultstring {$detail}" set code [lindex $detail 1] switch -exact -- $code { "VersionMismatch" { set code "SOAP-ENV:VersionMismatch" } "MustUnderstand" { set code "SOAP-ENV:MustUnderstand" } "Client" { set code "SOAP-ENV:Client" } "Server" { set code "SOAP-ENV:Server" } default { ## Do nothing } } switch -exact -- $flavor { rest { set doc [yajl create #auto] $doc map_open string "error" string $faultstring map_close set response [$doc get] $doc delete } soap { dom createDocument "SOAP-ENV:Envelope" doc $doc documentElement env $env setAttribute \ "xmlns:SOAP-ENV" "http://schemas.xmlsoap.org/soap/envelope/" \ "xmlns:xsi" "http://www.w3.org/1999/XMLSchema-instance" \ "xmlns:xsd" "http://www.w3.org/1999/XMLSchema" \ "xmlns:SOAP-ENC" "http://schemas.xmlsoap.org/soap/encoding/" $env appendChild [$doc createElement "SOAP-ENV:Body" bod] $bod appendChild [$doc createElement "SOAP-ENV:Fault" flt] $flt appendChild [$doc createElement "faultcode" fcd] $fcd appendChild [$doc createTextNode $faultcode] $flt appendChild [$doc createElement "faultstring" fst] $fst appendChild [$doc createTextNode $faultstring] if { $detail != {} } { $flt appendChild [$doc createElement "SOAP-ENV:detail" dtl0] $dtl0 appendChild [$doc createElement "e:errorInfo" dtl] $dtl setAttribute "xmlns:e" "urn:TclErrorInfo" foreach {detailName detailInfo} $detail { if {!$includeTrace && $detailName == "stackTrace"} { continue } $dtl appendChild [$doc createElement $detailName err] $err appendChild [$doc createTextNode $detailInfo] } } # serialize the DOM document and return the XML text append response \ {<?xml version="1.0" encoding="utf-8"?>} \ "\n" \ [$doc asXML -indent none -doctypeDeclaration 0] $doc delete } default { error "unsupported flavor" } } ::log::log debug "Leaving (error) ::WS::Server::generateError $response" return $response } ########################################################################### # # Private Procedure Header - as this procedure is modified, please be sure # that you update this header block. Thanks. # #>>BEGIN PRIVATE<< # # Procedure Name : :WS::Server::generateReply # # Description : Generate the reply packet for an operation # # Arguments : # serviceName - The name of the service # operation - The name of the operation # results - The results as a dictionary object # flavor - Output mode: "soap" or "rest" # # # Returns : The results as an XML formatted packet. # # Side-Effects : None # # Exception Conditions : None |
︙ | ︙ | |||
1595 1596 1597 1598 1599 1600 1601 | # # Version Date Programmer Comments / Changes / Reasons # ------- ---------- ---------- ------------------------------------------- # 1 07/06/2006 G.Lester Initial version # # ########################################################################### | | > > > > > > > > > > > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > > > > | | | 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 | # # Version Date Programmer Comments / Changes / Reasons # ------- ---------- ---------- ------------------------------------------- # 1 07/06/2006 G.Lester Initial version # # ########################################################################### proc ::WS::Server::generateReply {serviceName operation results flavor} { ::log::log debug "Entering ::WS::Server::generateReply $serviceName $operation {$results}" variable serviceArr array set serviceData $serviceArr($serviceName) switch -exact -- $flavor { rest { set doc [yajl create #auto -beautify $serviceData(-beautifyJson)] $doc map_open ::WS::Utils::convertDictToJson Server $serviceName $doc $results ${serviceName}:${operation}Results $serviceData(-enforceRequired) $doc map_close set output [$doc get] $doc delete } soap { if {[info exists ::Config(docRoot)] && [file exists [file join $::Config(docRoot) $serviceName $operation.css]]} { set replaceText [format {<?xml-stylesheet type="text/xsl" href="http://%s/css/%s/%s.css"?>}\ $serviceData(-host) \ $serviceName \ $operation] append replaceText "\n" } else { set replaceText {} } dom createDocument "SOAP-ENV:Envelope" doc $doc documentElement env $env setAttribute \ "xmlns:SOAP-ENV" "http://schemas.xmlsoap.org/soap/envelope/" \ "xmlns:xsi" "http://www.w3.org/1999/XMLSchema-instance" \ "xmlns:xsd" "http://www.w3.org/1999/XMLSchema" \ "xmlns:SOAP-ENC" "http://schemas.xmlsoap.org/soap/encoding/" \ xmlns:$serviceName "http://$serviceData(-host)$serviceData(-prefix)" if {[llength $serviceData(-outheaders)]} { $env appendChild [$doc createElement "SOAP-ENV:Header" header] foreach headerType $serviceData(-outheaders) { #$header appendChild [$doc createElement ${serviceName}:${headerType} part] #::WS::Utils::convertDictToType Server $serviceName $doc $part $results $headerType ::WS::Utils::convertDictToType Server $serviceName $doc $header $results $headerType 0 $serviceData(-enforceRequired) } } $env appendChild [$doc createElement "SOAP-ENV:Body" body] $body appendChild [$doc createElement ${serviceName}:${operation}Results reply] ::WS::Utils::convertDictToType Server $serviceName $doc $reply $results ${serviceName}:${operation}Results 0 $serviceData(-enforceRequired) append output \ {<?xml version="1.0" encoding="utf-8"?>} \ "\n" \ [$doc asXML -indent none -doctypeDeclaration 0] #regsub "<!DOCTYPE\[^>\]*>\n" [::dom::DOMImplementation serialize $doc] $replaceText xml $doc delete } default { error "Unsupported flavor" } } ::log::log debug "Leaving ::WS::Server::generateReply $output" return $output } ########################################################################### # # Private Procedure Header - as this procedure is modified, please be sure # that you update this header block. Thanks. |
︙ | ︙ | |||
1913 1914 1915 1916 1917 1918 1919 | append msg [::html::closeTag] append msg "\n" append msg [::html::h4 {Inputs}] "\n" append msg [::html::openTag div {style="margin-left: 40px;"}] | > > | | | | | | | | | | | | | | | | > > > | 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 | append msg [::html::closeTag] append msg "\n" append msg [::html::h4 {Inputs}] "\n" append msg [::html::openTag div {style="margin-left: 40px;"}] if {[llength [dict get $procInfo $service op$oper argOrder]]} { append msg [::html::openTag {table} {border="2"}] append msg [::html::hdrRow Name Type Description] foreach arg [dict get $procInfo $service op$oper argOrder] { ::log::log debug "\t\t\tDisplaying '$arg'" if {[dict exists $procInfo $service op$oper argList $arg comment]} { set comment [dict get $procInfo $service op$oper argList $arg comment] } else { set comment {} } append msg [::html::row \ $arg \ [displayType $service [dict get $procInfo $service op$oper argList $arg type]] \ $comment \ ] } append msg [::html::closeTag] } else { append msg "No inputs." } append msg [::html::closeTag] ::log::log debug "\t\tReturns" append msg [::html::h4 {Returns}] "\n" append msg [::html::openTag div {style="margin-left: 40px;"}] append msg [::html::openTag {table} {border="2"}] |
︙ | ︙ | |||
2016 2017 2018 2019 2020 2021 2022 2023 | ::log::log debug "\tDisplay custom types" set service [dict get $serviceInfo -service] append msg [::html::h2 {<a id='CustomTypeDetails'>Custom Types</a>}] set localTypeInfo [::WS::Utils::GetServiceTypeDef Server $service] foreach type [lsort -dictionary [dict keys $localTypeInfo]] { ::log::log debug "\t\tDisplaying '$type'" set typeOverloadArray($type) 1 | > | | > > > > > | > | 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 | ::log::log debug "\tDisplay custom types" set service [dict get $serviceInfo -service] append msg [::html::h2 {<a id='CustomTypeDetails'>Custom Types</a>}] set localTypeInfo [::WS::Utils::GetServiceTypeDef Server $service] foreach type [lsort -dictionary [dict keys $localTypeInfo]] { ::log::log debug "\t\tDisplaying '$type'" set href_type [lindex [split $type :] end] set typeOverloadArray($type) 1 append msg [::html::h3 "<a id='type_${href_type}'>$type</a>"] set typeDetails [dict get $localTypeInfo $type definition] append msg [::html::openTag {table} {border="2"}] append msg [::html::hdrRow Field Type Comment] foreach part [lsort -dictionary [dict keys $typeDetails]] { ::log::log debug "\t\t\tDisplaying '$part'" if {[dict exists $typeDetails $part comment]} { set comment [dict get $typeDetails $part comment] } else { set comment {} } append msg [::html::row \ $part \ [displayType $service [dict get $typeDetails $part type]] \ $comment ] } append msg [::html::closeTag] } append msg "\n<br/>\n<center>" [::html::minorMenu $menuList] "</center>" append msg "\n<hr/>\n" |
︙ | ︙ |
Changes to Utilities.tcl.
︙ | ︙ | |||
55 56 57 58 59 60 61 | } } package require log package require tdom 0.8 package require struct::set | | > > > > > > > > > > > > > > > > > > > > > > | 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | } } package require log package require tdom 0.8 package require struct::set package provide WS::Utils 2.4.0 namespace eval ::WS {} namespace eval ::WS::Utils { set ::WS::Utils::typeInfo {} set ::WS::Utils::currentSchema {} array set ::WS::Utils::importedXref {} set nsList { w http://schemas.xmlsoap.org/wsdl/ d http://schemas.xmlsoap.org/wsdl/soap/ xs http://www.w3.org/2001/XMLSchema } # mapping of how the simple SOAP types should be serialized using YAJL into JSON. array set ::WS::Utils::simpleTypesJson { boolean "bool" float "number" double "double" integer "integer" int "integer" long "integer" short "integer" byte "integer" nonPositiveInteger "integer" negativeInteger "integer" nonNegativeInteger "integer" unsignedLong "integer" unsignedInt "integer" unsignedShort "integer" unsignedByte "integer" positiveInteger "integer" decimal "number" } array set ::WS::Utils::simpleTypes { anyType 1 string 1 boolean 1 decimal 1 float 1 double 1 |
︙ | ︙ | |||
125 126 127 128 129 130 131 | parseInAttr 0 genOutAttr 0 valueAttrCompatiblityMode 1 includeDirectory {} suppressNS {} useTypeNs 0 nsOnChangeOnly 0 | | | 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | parseInAttr 0 genOutAttr 0 valueAttrCompatiblityMode 1 includeDirectory {} suppressNS {} useTypeNs 0 nsOnChangeOnly 0 anyType string } set ::WS::Utils::standardAttributes { baseType comment pattern length |
︙ | ︙ | |||
215 216 217 218 219 220 221 | proc ::WS::Utils::GetCrossreference {mode service} { variable typeInfo array set crossreference {} dict for {type typeDict} [dict get $typeInfo $mode $service] { foreach {field fieldDict} [dict get $typeDict definition] { | | | 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | proc ::WS::Utils::GetCrossreference {mode service} { variable typeInfo array set crossreference {} dict for {type typeDict} [dict get $typeInfo $mode $service] { foreach {field fieldDict} [dict get $typeDict definition] { set fieldType [string trimright [dict get $fieldDict type] {()?}] incr crossreference($fieldType,count) lappend crossreference($fieldType,usedBy) $type.$field } if {![info exists crossreference($type,count) ]} { set crossreference($type,count) 0 set crossreference($type,usedBy) {} } |
︙ | ︙ | |||
561 562 563 564 565 566 567 | # # ########################################################################### proc ::WS::Utils::GetServiceTypeDef {mode service {type {}}} { variable typeInfo variable simpleTypes | | | 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 | # # ########################################################################### proc ::WS::Utils::GetServiceTypeDef {mode service {type {}}} { variable typeInfo variable simpleTypes set type [string trimright $type {()?}] set results {} if {[string equal $type {}]} { ::log::log debug "@1" set results [dict get $typeInfo $mode $service] } else { set typeInfoList [TypeInfo $mode $service $type] if {[string equal -nocase -length 3 $type {xs:}]} { |
︙ | ︙ | |||
651 652 653 654 655 656 657 | # 1 07/06/2006 G.Lester Initial version # # ########################################################################### proc ::WS::Utils::GetServiceSimpleTypeDef {mode service {type {}}} { variable simpleTypes | | | 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 | # 1 07/06/2006 G.Lester Initial version # # ########################################################################### proc ::WS::Utils::GetServiceSimpleTypeDef {mode service {type {}}} { variable simpleTypes set type [string trimright $type {()?}] if {[string equal -nocase -length 3 $type {xs:}]} { return [::WS::Utils::GetServiceTypeDef $mode $service $type] } if {[string equal $type {}]} { set results {} foreach {key value} [array get simpleTypes $mode,$service,*] { lappend results [list [lindex [split $key {,}] end] $simpleTypes($key)] |
︙ | ︙ | |||
911 912 913 914 915 916 917 | # that you update this header block. Thanks. # #>>BEGIN PUBLIC<< # # Procedure Name : ::WS::Utils::TypeInfo # # Description : Return a list indicating if the type is simple or complex | | | 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 | # that you update this header block. Thanks. # #>>BEGIN PUBLIC<< # # Procedure Name : ::WS::Utils::TypeInfo # # Description : Return a list indicating if the type is simple or complex # and if it is a scalar or an array. Also if it is optional # # Arguments : # type - the type name, possibly with a () to specify it is an array # # Returns : A list of two elements, as follows: # 0|1 - 0 means a simple type, 1 means a complex type # 0|1 - 0 means a scalar, 1 means an array |
︙ | ︙ | |||
941 942 943 944 945 946 947 | # Version Date Programmer Comments / Changes / Reasons # ------- ---------- ---------- ------------------------------------------- # 1 07/06/2006 G.Lester Initial version # 2.3.0 10/16/2012 G. Lester Corrected detection of service specific simple type. # 2.3.0 10/31/2012 G. Lester Corrected missing newline. # ########################################################################### | | > > > > > > > > | 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 | # Version Date Programmer Comments / Changes / Reasons # ------- ---------- ---------- ------------------------------------------- # 1 07/06/2006 G.Lester Initial version # 2.3.0 10/16/2012 G. Lester Corrected detection of service specific simple type. # 2.3.0 10/31/2012 G. Lester Corrected missing newline. # ########################################################################### proc ::WS::Utils::TypeInfo {mode service type {findOptional 0}} { variable simpleTypes variable typeInfo set type [string trim $type] set isOptional 0 if {[string equal [string index $type end] {?}]} { set isOptional 1 set type [string trimright $type {?}] } if {[string equal [string range $type end-1 end] {()}]} { set isArray 1 set type [string range $type 0 end-2] } elseif {[string equal $type {array}]} { set isArray 1 } else { set isArray 0 } #set isNotSimple [dict exists $typeInfo $mode $service $type] #set isNotSimple [expr {$isNotSimple || [dict exists $typeInfo $mode $service $service:$type]}] lassign [split $type {:}] tns baseType set isNotSimple [expr {!([info exist simpleTypes($type)] || [info exist simpleTypes($baseType)] || [info exist simpleTypes($mode,$service,$type)] || [info exist simpleTypes($mode,$service,$baseType)] )}] if {$findOptional} { return [list $isNotSimple $isArray $isOptional] } return [list $isNotSimple $isArray] } ########################################################################### # # Public Procedure Header - as this procedure is modified, please be sure |
︙ | ︙ | |||
1270 1271 1272 1273 1274 1275 1276 | # 1 07/06/2006 G.Lester Initial version # 2 02/03/2008 G.Lester Moved into WS::Utils namespace # ########################################################################### proc ::WS::Utils::getTypeWSDLInfo {mode serviceName field type} { set typeInfo {maxOccurs 1 minOccurs 1 name * type *} dict set typeInfo name $field | | | | > > > | 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 | # 1 07/06/2006 G.Lester Initial version # 2 02/03/2008 G.Lester Moved into WS::Utils namespace # ########################################################################### proc ::WS::Utils::getTypeWSDLInfo {mode serviceName field type} { set typeInfo {maxOccurs 1 minOccurs 1 name * type *} dict set typeInfo name $field set typeList [TypeInfo $mode $serviceName $type 1] if {[lindex $typeList 0] == 0} { dict set typeInfo type xs:[string trimright $type {()?}] } else { dict set typeInfo type $serviceName:[string trimright $type {()?}] } if {[lindex $typeList 1]} { dict set typeInfo maxOccurs unbounded } if {[lindex $typeList 2]} { dict set typeInfo minOccurs 0 } return $typeInfo } ########################################################################### |
︙ | ︙ | |||
1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 | # } #} set partsList [dict keys [dict get $typeDefInfo definition]] ::log::log debug "\t partsList is {$partsList}" set arrayOverride [expr {$isArray && ([llength $partsList] == 1)}] foreach partName $partsList { set partType [dict get $typeDefInfo definition $partName type] if {[dict exists $typeDefInfo definition $partName allowAny] && [dict get $typeDefInfo definition $partName allowAny]} { set allowAny 1 } else { set allowAny 0 } if {[string equal $partName *] && [string equal $partType *]} { ## | > | 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 | # } #} set partsList [dict keys [dict get $typeDefInfo definition]] ::log::log debug "\t partsList is {$partsList}" set arrayOverride [expr {$isArray && ([llength $partsList] == 1)}] foreach partName $partsList { set partType [dict get $typeDefInfo definition $partName type] set partType [string trimright $partType {?}] if {[dict exists $typeDefInfo definition $partName allowAny] && [dict get $typeDefInfo definition $partName allowAny]} { set allowAny 1 } else { set allowAny 0 } if {[string equal $partName *] && [string equal $partType *]} { ## |
︙ | ︙ | |||
1465 1466 1467 1468 1469 1470 1471 | set isAbstract [dict get $typeInfo $mode $serviceName $partType abstract] } switch -exact -- $typeInfoList { {0 0} { ## ## Simple non-array ## | | | | | | | 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 | set isAbstract [dict get $typeInfo $mode $serviceName $partType abstract] } switch -exact -- $typeInfoList { {0 0} { ## ## Simple non-array ## if {[dict exists $tmpTypeInfo base]} { set baseType [dict get $tmpTypeInfo base] } else { set baseType string } if {$options(parseInAttr)} { foreach attrList [$item attributes] { catch { lassign $attrList attr nsAlias nsUrl if {[string equal $nsUrl $xsiNsUrl]} { set attrValue [$item getAttribute ${nsAlias}:$attr] dict set results $partName ::$attr $attrValue |
︙ | ︙ | |||
1503 1504 1505 1506 1507 1508 1509 | } } } {0 1} { ## ## Simple array ## | | | | | | | 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 | } } } {0 1} { ## ## Simple array ## if {[dict exists $tmpTypeInfo base]} { set baseType [dict get $tmpTypeInfo base] } else { set baseType string } set tmp {} foreach row $item { if {$options(parseInAttr)} { set rowList {} foreach attrList [$row attributes] { catch { lassign $attrList attr nsAlias nsUrl |
︙ | ︙ | |||
1706 1707 1708 1709 1710 1711 1712 | # # Version Date Programmer Comments / Changes / Reasons # ------- ---------- ---------- ------------------------------------------- # 1 07/06/2006 G.Lester Initial version # # ########################################################################### | | | > | 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 | # # Version Date Programmer Comments / Changes / Reasons # ------- ---------- ---------- ------------------------------------------- # 1 07/06/2006 G.Lester Initial version # # ########################################################################### proc ::WS::Utils::convertDictToType {mode service doc parent dict type {forceNs 0} {enforceRequired 0}} { ::log::log debug "Entering ::WS::Utils::convertDictToType $mode $service $doc $parent {$dict} $type" # ::log::log debug " Parent xml: [$parent asXML]" variable typeInfo variable simpleTypes variable options variable standardAttributes variable currentNs if {!$options(UseNS)} { return [::WS::Utils::convertDictToTypeNoNs $mode $service $doc $parent $dict $type $enforceRequired] } if {$options(valueAttrCompatiblityMode)} { set valueAttr {} } else { set valueAttr {::value} } set typeInfoList [TypeInfo $mode $service $type] set type [string trimright $type {?}] ::log::log debug "\t typeInfoList = {$typeInfoList}" if {[dict exists $typeInfo $mode $service $service:$type]} { set typeName $service:$type } else { set typeName $type } set itemList {} |
︙ | ︙ | |||
1773 1774 1775 1776 1777 1778 1779 | } set fieldList {} foreach {itemName itemDef} $itemList { set baseName [lindex [split $itemName {:}] end] lappend fieldList $itemName set itemType [dict get $itemDef type] ::log::log debug "\t\titemName = {$itemName} itemDef = {$itemDef} itemType ={$itemType}" | | > > > > | | | > > | 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 | } set fieldList {} foreach {itemName itemDef} $itemList { set baseName [lindex [split $itemName {:}] end] lappend fieldList $itemName set itemType [dict get $itemDef type] ::log::log debug "\t\titemName = {$itemName} itemDef = {$itemDef} itemType ={$itemType}" set typeInfoList [TypeInfo $mode $service $itemType 1] ::log::log debug "Expr [list ![dict exists $dict $itemName] && ![dict exists $dict $baseName]]" if {![dict exists $dict $itemName] && ![dict exists $dict $baseName]} { ::log::log debug "Neither {$itemName} nor {$baseName} are in dictionary {$dict}, skipping" # If required parameters are being enforced and this field is not optional, throw an error if {$enforceRequired && ![lindex $typeInfoList 2]} { error "Required field $itemName is missing from response" } continue } elseif {[dict exists $dict $baseName]} { set useName $baseName } else { set useName $itemName } set itemXns $xns set tmpInfo [GetServiceTypeDef $mode $service [string trimright $itemType {()?}]] if {$options(useTypeNs) && [dict exists $tmpInfo xns]} { set itemXns [dict get $tmpInfo xns] } set attrList {} if {$options(useTypeNs) && [string equal $itemXns xs]} { set itemXns $xns } if {$options(nsOnChangeOnly) && [string equal $itemXns $currentNs]} { set itemXns {} } foreach key [dict keys $itemDef] { if {[lsearch -exact $standardAttributes $key] == -1 && $key ne "isList" && $key ne "xns"} { lappend attrList $key [dict get $itemDef $key] ::log::log debug "key = {$key} standardAttributes = {$standardAttributes}" } } ::log::log debug "\t\titemName = {$itemName} itemDef = {$itemDef} typeInfoList = {$typeInfoList} itemXns = {$itemXns} tmpInfo = {$tmpInfo} attrList = {$attrList}" set isAbstract false set baseType [string trimright $itemType {()?}] if {$options(genOutAttr) && [dict exists $typeInfo $mode $service $baseType abstract]} { set isAbstract [dict get $typeInfo $mode $service $baseType abstract] } ::log::log debug "\t\titemName = {$itemName} itemDef = {$itemDef} typeInfoList = {$typeInfoList} isAbstract = {$isAbstract}" # Strip the optional flag off the typeInfoList set typeInfoList [lrange $typeInfoList 0 1] switch -exact -- $typeInfoList { {0 0} { ## ## Simple non-array ## if {[string equal $itemXns $options(suppressNS)] || [string equal $itemXns {}]} { $parent appendChild [$doc createElement $itemName retNode] |
︙ | ︙ | |||
1920 1921 1922 1923 1924 1925 1926 | } } else { set resultValue [dict get $dict $useName] } if {![string equal $currentNs $itemXns] && ![string equal $itemXns {}]} { set tmpNs $currentNs set currentNs $itemXns | | | < | 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 | } } else { set resultValue [dict get $dict $useName] } if {![string equal $currentNs $itemXns] && ![string equal $itemXns {}]} { set tmpNs $currentNs set currentNs $itemXns convertDictToType $mode $service $doc $retNode $resultValue $itemType $forceNs $enforceRequired } else { convertDictToType $mode $service $doc $retNode $resultValue $itemType $forceNs $enforceRequired } if {[llength $attrList]} { ::WS::Utils::setAttr $retNode $attrList } } {1 1} { ## ## Non-simple array ## set dataList [dict get $dict $useName] #::log::log debug "\t\t [llength $dataList] rows {$dataList}" foreach row $dataList { if {[string equal $itemXns $options(suppressNS)] || [string equal $itemXns {}]} { $parent appendChild [$doc createElement $itemName retNode] } else { $parent appendChild [$doc createElement $itemXns:$itemName retNode] } |
︙ | ︙ | |||
1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 | } else { lappend attrList $attr [dict get $row $attr] } } } else { set resultValue $row } if {![string equal $currentNs $itemXns] && ![string equal $itemXns {}]} { set tmpNs $currentNs set currentNs $itemXns | > > > > > | | | 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 | } else { lappend attrList $attr [dict get $row $attr] } } } else { set resultValue $row } if {[string index $itemType end] eq {?}} { set tmpType "[string trimright $itemType {()?}]?" } else { set tmpType [string trimright $itemType {()}] } if {![string equal $currentNs $itemXns] && ![string equal $itemXns {}]} { set tmpNs $currentNs set currentNs $itemXns convertDictToType $mode $service $doc $retNode $resultValue $tmpType $forceNs $enforceRequired } else { convertDictToType $mode $service $doc $retNode $resultValue $tmpType $forceNs $enforceRequired } if {[llength $attrList]} { ::WS::Utils::setAttr $retNode $attrList } } } default { |
︙ | ︙ | |||
1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 | # } #} } set currentNs $entryNs ::log::log debug "Leaving ::WS::Utils::convertDictToType with xml: [$parent asXML]" return; } ########################################################################### # # Private Procedure Header - as this procedure is modified, please be sure # that you update this header block. Thanks. # #>>BEGIN PRIVATE<< | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 | # } #} } set currentNs $entryNs ::log::log debug "Leaving ::WS::Utils::convertDictToType with xml: [$parent asXML]" return; } ########################################################################### # # Private Procedure Header - as this procedure is modified, please be sure # that you update this header block. Thanks. # #>>BEGIN PRIVATE<< # # Procedure Name : ::WS::Utils::convertDictToJson # # Description : Convert a dictionary object into a JSON tree. # # Arguments : # mode - The mode, Client or Server # service - The service name the type is defined in # doc - The document (yajltcl) # dict - The dictionary to convert # type - The name of the type # # Returns : None # # Side-Effects : None # # Exception Conditions : None # # Pre-requisite Conditions : None # # Original Author : Jeff Lawson # #>>END PRIVATE<< # # Maintenance History - as this file is modified, please be sure that you # update this segment of the file header block by # adding a complete entry at the bottom of the list. # # Version Date Programmer Comments / Changes / Reasons # ------- ---------- ---------- ------------------------------------------- # 1 03/23/2011 J.Lawson Initial version # # ########################################################################### proc ::WS::Utils::convertDictToJson {mode service doc dict type {enforceRequired 0}} { ::log::log debug "Entering ::WS::Utils::convertDictToJson $mode $service $doc {$dict} $type" variable typeInfo variable simpleTypes variable simpleTypesJson variable options variable standardAttributes set typeInfoList [TypeInfo $mode $service $type] set type [string trimright $type {?}] if {[dict exists $typeInfo $mode $service $service:$type]} { set typeName $service:$type } else { set typeName $type } set itemList {} if {[lindex $typeInfoList 0] && [dict exists $typeInfo $mode $service $typeName definition]} { set itemList [dict get $typeInfo $mode $service $typeName definition] set xns [dict get $typeInfo $mode $service $typeName xns] } else { set xns $simpleTypes($mode,$service,$typeName) set itemList [list $typeName {type string}] } if {[info exists mutableTypeInfo([list $mode $service $typeName])]} { set typeName [(*)[lindex mutableTypeInfo([list $mode $service $type]) 0] $mode $service $type $xns $dict] set typeInfoList [TypeInfo $mode $service $typeName] if {[lindex $typeInfoList 0]} { set itemList [dict get $typeInfo $mode $service $typeName definition] } else { set itemList [list $type {type string}] } } ::log::log debug "\titemList is {$itemList}" set fieldList {} foreach {itemName itemDef} $itemList { lappend fieldList $itemName set itemType [dict get $itemDef type] ::log::log debug "\t\titemName = {$itemName} itemDef = {$itemDef} itemType = {$itemType}" set typeInfoList [TypeInfo $mode $service $itemType 1] if {![dict exists $dict $itemName]} { if {$enforceRequired && ![lindex $typeInfoList 2]} { error "Required field $itemName is missing from response" } continue } if {[info exists simpleTypesJson([string trimright $itemType {()?}])]} { set yajlType $simpleTypesJson([string trimright $itemType {()?}]) } else { set yajlType "string" } ::log::log debug "\t\titemName = {$itemName} itemDef = {$itemDef} typeInfoList = {$typeInfoList}" set typeInfoList [lrange $typeInfoList 0 1] switch $typeInfoList { {0 0} { ## ## Simple non-array ## set resultValue [dict get $dict $itemName] $doc string $itemName $yajlType $resultValue } {0 1} { ## ## Simple array ## set dataList [dict get $dict $itemName] $doc string $itemName array_open foreach row $dataList { $doc $yajlType $row } $doc array_close } {1 0} { ## ## Non-simple non-array ## $doc string $itemName map_open set resultValue [dict get $dict $itemName] convertDictToJson $mode $service $doc $resultValue $itemType $enforceRequired $doc map_close } {1 1} { ## ## Non-simple array ## set dataList [dict get $dict $itemName] $doc string $itemName array_open if {[string index $itemType end] eq {?}} { set tmpType "[string trimright $itemType {()?}]?" } else { set tmpType [string trimright $itemType {()}] } foreach row $dataList { $doc map_open convertDictToJson $mode $service $doc $row $tmpType $enforceRequired $doc map_close } $doc array_close } } } return; } ########################################################################### # # Private Procedure Header - as this procedure is modified, please be sure # that you update this header block. Thanks. # #>>BEGIN PRIVATE<< |
︙ | ︙ | |||
2033 2034 2035 2036 2037 2038 2039 | # # Version Date Programmer Comments / Changes / Reasons # ------- ---------- ---------- ------------------------------------------- # 1 07/06/2006 G.Lester Initial version # # ########################################################################### | | | 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 | # # Version Date Programmer Comments / Changes / Reasons # ------- ---------- ---------- ------------------------------------------- # 1 07/06/2006 G.Lester Initial version # # ########################################################################### proc ::WS::Utils::convertDictToTypeNoNs {mode service doc parent dict type {enforceRequired 0}} { ::log::log debug "Entering ::WS::Utils::convertDictToTypeNoNs $mode $service $doc $parent {$dict} $type" # ::log::log debug " Parent xml: [$parent asXML]" variable typeInfo variable simpleTypes variable options variable standardAttributes |
︙ | ︙ | |||
2065 2066 2067 2068 2069 2070 2071 | set itemList [list $type {type string}] } ::log::log debug "\titemList is {$itemList}" foreach {itemName itemDef} $itemList { ::log::log debug "\t\titemName = {$itemName} itemDef = {$itemDef}" set itemType [dict get $itemDef type] set isAbstract false | | | > > > > | 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 | set itemList [list $type {type string}] } ::log::log debug "\titemList is {$itemList}" foreach {itemName itemDef} $itemList { ::log::log debug "\t\titemName = {$itemName} itemDef = {$itemDef}" set itemType [dict get $itemDef type] set isAbstract false set baseType [string trimright $itemType {()?}] if {$options(genOutAttr) && [dict exists $typeInfo $mode $service $baseType abstract]} { set isAbstract [dict get $typeInfo $mode $service $baseType abstract] } set typeInfoList [TypeInfo $mode $service $itemType 1] if {![dict exists $dict $itemName]} { if {$enforceRequired && ![lindex $typeInfoList 2]} { error "Required field $itemName is missing from response" } continue } set attrList {} foreach key [dict keys $itemDef] { if {[lsearch -exact $standardAttributes $key] == -1 && $key ne "isList" && $key ne "xns"} { lappend attrList $key [dict get $itemDef $key] ::log::log debug "key = {$key} standardAttributes = {$standardAttributes}" } } ::log::log debug "\t\titemName = {$itemName} itemDef = {$itemDef} typeInfoList = {$typeInfoList}" set typeInfoList [lrange $typeInfoList 0 1] switch -exact -- $typeInfoList { {0 0} { ## ## Simple non-array ## $parent appendChild [$doc createElement $itemName retNode] if {$options(genOutAttr)} { |
︙ | ︙ | |||
2167 2168 2169 2170 2171 2172 2173 | } } else { set resultValue [dict get $dict $itemName] } if {[llength $attrList]} { ::WS::Utils::setAttr $retNode $attrList } | | | | 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 | } } else { set resultValue [dict get $dict $itemName] } if {[llength $attrList]} { ::WS::Utils::setAttr $retNode $attrList } convertDictToTypeNoNs $mode $service $doc $retnode $resultValue $itemType $enforceRequired } {1 1} { ## ## Non-simple array ## set dataList [dict get $dict $itemName] set tmpType [string trimright $itemType {()}] foreach row $dataList { $parent appendChild [$doc createElement $itemName retnode] if {$options(genOutAttr)} { set dictList [dict keys $row] set resultValue {} foreach attr [lindex [::struct::set intersect3 $standardAttributes $dictList] end] { if {$isAbstract && [string equal $attr {::type}]} { |
︙ | ︙ | |||
2200 2201 2202 2203 2204 2205 2206 | } } else { set resultValue $row } if {[llength $attrList]} { ::WS::Utils::setAttr $retNode $attrList } | | | 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 | } } else { set resultValue $row } if {[llength $attrList]} { ::WS::Utils::setAttr $retNode $attrList } convertDictToTypeNoNs $mode $service $doc $retnode $resultValue $tmpType $enforceRequired } } default { ## ## Placed here to shut up tclchecker ## } |
︙ | ︙ | |||
2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 | ::log::log debug "Entering ::WS::Utils::convertDictToEncodedType $mode $service $doc $parent {$dict} $type" variable typeInfo variable options set typeInfoList [TypeInfo $mode $service $type] ::log::log debug "\t typeInfoList = {$typeInfoList}" if {[lindex $typeInfoList 0]} { set itemList [dict get $typeInfo $mode $service $type definition] set xns [dict get $typeInfo $mode $service $type xns] } else { if {[info exists simpleTypes($mode,$service,$type)]} { set xns [dict get $simpleTypes($mode,$service,$type) xns] } else { | > | 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 | ::log::log debug "Entering ::WS::Utils::convertDictToEncodedType $mode $service $doc $parent {$dict} $type" variable typeInfo variable options set typeInfoList [TypeInfo $mode $service $type] ::log::log debug "\t typeInfoList = {$typeInfoList}" set type [string trimright $type {?}] if {[lindex $typeInfoList 0]} { set itemList [dict get $typeInfo $mode $service $type definition] set xns [dict get $typeInfo $mode $service $type xns] } else { if {[info exists simpleTypes($mode,$service,$type)]} { set xns [dict get $simpleTypes($mode,$service,$type) xns] } else { |
︙ | ︙ | |||
2291 2292 2293 2294 2295 2296 2297 | error "Simple type cannot be found: $type" } set itemList [list $type {type string}] } } ::log::log debug "\titemList is {$itemList} in $xns" foreach {itemName itemDef} $itemList { | | | 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 | error "Simple type cannot be found: $type" } set itemList [list $type {type string}] } } ::log::log debug "\titemList is {$itemList} in $xns" foreach {itemName itemDef} $itemList { set itemType [string trimright [dict get $itemList $itemName type] {?}] set typeInfoList [TypeInfo $mode $service $itemType] ::log::log debug "\t\t Looking for {$itemName} in {$dict}" if {![dict exists $dict $itemName]} { ::log::log debug "\t\t Not found, skipping" continue } ::log::log debug "\t\t Type info is {$typeInfoList}" |
︙ | ︙ | |||
2367 2368 2369 2370 2371 2372 2373 | set dataList [dict get $dict $itemName] set tmpType [string trimright $itemType {()}] if {![string match {*:*} $itemType]} { set attrType $xns:$itemType } else { set attrType $itemType } | | | 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 | set dataList [dict get $dict $itemName] set tmpType [string trimright $itemType {()}] if {![string match {*:*} $itemType]} { set attrType $xns:$itemType } else { set attrType $itemType } set attrType [string trim $attrType {()?}] $parent setAttribute xmlns:soapenc {http://schemas.xmlsoap.org/soap/encoding/} $parent setAttribute soapenc:arrayType [format {%s[%d]} $attrType [llength $dataList]] $parent setAttribute xsi:type soapenc:Array #set itemName [$parent nodeName] foreach item $dataList { if {[string equal $xns $options(suppressNS)]} { $parent appendChild [$doc createElement $itemName retNode] |
︙ | ︙ | |||
2669 2670 2671 2672 2673 2674 2675 | warning { set ::WS::Utils::targetNs $tmpTargetNs ::log::log $options(StrictMode) "Found $lastUnknownRefCount forward type references: [join [array names unkownRef] {,}]" } error - default { set ::WS::Utils::targetNs $tmpTargetNs | < | 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 | warning { set ::WS::Utils::targetNs $tmpTargetNs ::log::log $options(StrictMode) "Found $lastUnknownRefCount forward type references: [join [array names unkownRef] {,}]" } error - default { set ::WS::Utils::targetNs $tmpTargetNs return \ -code error \ -errorcode [list WS $mode UNKREFS [list $lastUnknownRefCount]] \ "Found $lastUnknownRefCount forward type references: [join [array names unkownRef] {,}]" } } } |
︙ | ︙ | |||
2910 2911 2912 2913 2914 2915 2916 | -code error \ -errorcode [list WS CLIENT MISSCHLOC $baseUrl] \ "Missing Schema Location in '$baseUrl'" } } set urlTail [$importNode getAttribute $attrName] set url [::uri::resolve $baseUrl $urlTail] | | | 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 | -code error \ -errorcode [list WS CLIENT MISSCHLOC $baseUrl] \ "Missing Schema Location in '$baseUrl'" } } set urlTail [$importNode getAttribute $attrName] set url [::uri::resolve $baseUrl $urlTail] ::log::log debug "Including $url" set lastPos [string last / $url] set testUrl [string range $url 0 [expr {$lastPos - 1}]] if { [info exists ::WS::Utils::redirectArray($testUrl)] } { set newUrl $::WS::Utils::redirectArray($testUrl) append newUrl [string range $url $lastPos end] ::log::log debug "newUrl = $newUrl" |
︙ | ︙ | |||
3129 3130 3131 3132 3133 3134 3135 | return \ -code error \ -errorcode [list WS $mode UNKREF [list $typeName $partType]] \ "Unknown forward type reference {$partType} in {$typeName}" } } else { set partName [$middleNode getAttribute name] | | | 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 | return \ -code error \ -errorcode [list WS $mode UNKREF [list $typeName $partType]] \ "Unknown forward type reference {$partType} in {$typeName}" } } else { set partName [$middleNode getAttribute name] set partType [string trimright [getQualifiedType $results [$middleNode getAttribute type string:string] $tns] {?}] set partMax [$middleNode getAttribute maxOccurs 1] if {$partMax <= 1} { lappend partList $partName [list type $partType comment $comment] } else { lappend partList $partName [list type [string trimright ${partType} {()}]() comment $comment] } } |
︙ | ︙ | |||
3196 3197 3198 3199 3200 3201 3202 | set ref $attr } catch {set attrArr($name) [$element getAttribute $ref]} } set partName item set partType [getQualifiedType $results $attrArr(arrayType) $tns] set partType [string map {{[]} {()}} $partType] | | | 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 | set ref $attr } catch {set attrArr($name) [$element getAttribute $ref]} } set partName item set partType [getQualifiedType $results $attrArr(arrayType) $tns] set partType [string map {{[]} {()}} $partType] lappend partList $partName [list type [string trimright ${partType} {()?}]() comment $comment allowAny 1] set nodeFound 1 } extension { ::log::log debug "Calling partList for $contentType of $typeName" if {[catch {set tmp [partList $mode $child $serviceName results $tns]} msg]} { ::log::log debug "Error in partList {$msg}, errorInfo: $errorInfo" } |
︙ | ︙ | |||
3325 3326 3327 3328 3329 3330 3331 | ## ## Do Nothing ## } element { catch { set partName [$node getAttribute name] | | | 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 | ## ## Do Nothing ## } element { catch { set partName [$node getAttribute name] set partType [string trimright [getQualifiedType $results [$node getAttribute type string] $tns] {?}] set partMax [$node getAttribute maxOccurs 1] if {$partMax <= 1} { set partList [list $partName [list type $partType comment {}]] } else { set partList [list $partName [list type [string trimright ${partType} {()}]() comment {}]] } } |
︙ | ︙ | |||
3401 3402 3403 3404 3405 3406 3407 | set attrName ref set isRef 1 } set partName [$element getAttribute $attrName] if {$isRef} { set partType {} set partTypeInfo {} | | | 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 | set attrName ref set isRef 1 } set partName [$element getAttribute $attrName] if {$isRef} { set partType {} set partTypeInfo {} set partType [string trimright [getQualifiedType $results $partName $tns] {?}] set partTypeInfo [::WS::Utils::GetServiceTypeDef $mode $serviceName $partType] set partName [lindex [split $partName {:}] end] ::log::log debug "\t\t\t part name is {$partName} type is {$partTypeInfo}" if {[dict exists $partTypeInfo definition $partName]} { set partType [dict get $partTypeInfo definition $partName type] } ::log::log debug "\t\t\t part name is {$partName} type is {$partType}" |
︙ | ︙ | |||
3450 3451 3452 3453 3454 3455 3456 | } } else { set partMax [$element getAttribute maxOccurs 1] } if {$partMax <= 1} { lappend partList $partName [concat [list type $partType comment $comment] $additional_defininition_elements] } else { | | | 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 | } } else { set partMax [$element getAttribute maxOccurs 1] } if {$partMax <= 1} { lappend partList $partName [concat [list type $partType comment $comment] $additional_defininition_elements] } else { lappend partList $partName [concat [list type [string trimright ${partType} {()?}]() comment $comment] $additional_defininition_elements] } } msg]} { ::log::log error "\tError processing {$msg} for [$element asXML]" if {$isRef} { ::log::log error "\t\t Was a reference. Additionally information is:" ::log::log error "\t\t\t part name is {$partName} type is {$partType} with {$partTypeInfo}" } |
︙ | ︙ | |||
3486 3487 3488 3489 3490 3491 3492 | set ref $attr } catch {set attrArr($name) [$element getAttribute $ref]} } set partName item set partType [getQualifiedType $results $attrArr(arrayType) $tns] set partType [string map {{[]} {()}} $partType] | | | 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 | set ref $attr } catch {set attrArr($name) [$element getAttribute $ref]} } set partName item set partType [getQualifiedType $results $attrArr(arrayType) $tns] set partType [string map {{[]} {()}} $partType] set partList [list $partName [list type [string trimright ${partType} {()?}]() comment {} allowAny 1]] } extension { set extension [$node selectNodes -namespaces $nsList xs:extension] set partList [partList $mode $extension $serviceName results $tns] } default { ## |
︙ | ︙ | |||
3679 3680 3681 3682 3683 3684 3685 | if {[string equal $partMax -1]} { set partMax [[$element parent] getAttribute maxOccurs -1] } if {$partMax <= 1} { lappend partList $partName [list type $partType comment {}] } else { | | | 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 | if {[string equal $partMax -1]} { set partMax [[$element parent] getAttribute maxOccurs -1] } if {$partMax <= 1} { lappend partList $partName [list type $partType comment {}] } else { lappend partList $partName [list type [string trimright ${partType} {()?}]() comment {}] } } if {[llength $elements] == 0} { # # Validate this is not really a complex or simple type # set childList [$node childNodes] |
︙ | ︙ | |||
3732 3733 3734 3735 3736 3737 3738 | if {([lindex [TypeInfo $mode $serviceName $partType] 0] == 0) && [string equal $tns:$typeName $partType]} { return } else { lappend partList $typeName [list type $partType comment {}] } } else { | | | 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 | if {([lindex [TypeInfo $mode $serviceName $partType] 0] == 0) && [string equal $tns:$typeName $partType]} { return } else { lappend partList $typeName [list type $partType comment {}] } } else { lappend partList $typeName [list type [string trimright ${partType} {()?}]() comment {}] } } if {[llength $partList]} { ::WS::Utils::ServiceTypeDef $mode $serviceName $tns:$typeName $partList $tns $isAbstractType } else { if {![dict exists $results types $tns:$typeName]} { set partList [list base string comment {} xns $tns] |
︙ | ︙ | |||
3909 3910 3911 3912 3913 3914 3915 | ## set result 1 ## ## Get the type information ## set typeInfoList [TypeInfo $mode $serviceName $typeName] | | > | 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 | ## set result 1 ## ## Get the type information ## set typeInfoList [TypeInfo $mode $serviceName $typeName] set baseTypeName [string trimright $typeName {()?}] set typeName [string trimright $typeName {?}] set typeInfo [GetServiceTypeDef $mode $serviceName $baseTypeName] set isComplex [lindex $typeInfoList 0] set isArray [lindex $typeInfoList 1] if {$isComplex} { ## ## Is complex |
︙ | ︙ | |||
4102 4103 4104 4105 4106 4107 4108 | ########################################################################### proc ::WS::Utils::buildTags {mode serviceName typeName valueInfos doc currentNode} { upvar 1 $valueInfos values ## ## Get the type information ## | | > | | 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 | ########################################################################### proc ::WS::Utils::buildTags {mode serviceName typeName valueInfos doc currentNode} { upvar 1 $valueInfos values ## ## Get the type information ## set baseTypeName [string trimright $typeName {()?}] set typeInfo [GetServiceTypeDef $mode $serviceName $baseTypeName] set typeName [string trimright $typeName {?}] set xns [dict get $typeInfo $mode $service $type xns] foreach {field fieldDef} [dict get $typeInfo definition] { ## ## Get info about this field and its type ## array unset fieldInfoArr set fieldInfoArr(minOccurs) 0 array set fieldInfoArr $fieldDef set typeInfoList [TypeInfo $mode $serviceName $fieldInfoArr(type)] set fieldBaseType [string trimright $fieldInfoArr(type) {()?}] set isComplex [lindex $typeInfoList 0] set isArray [lindex $typeInfoList 1] if {[dict exists $valueInfos $field]} { if {$isArray} { set valueList [dict get $valueInfos $field] } else { set valueList [list [dict get $valueInfos $field]] |
︙ | ︙ | |||
4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 | set results {<** Circular Reference **>} ::log::log debug "Leaving [info level 0] with {$results}" return $results } else { set generatedTypes([list $mode $serviceName $type]) 1 } # set typeDefInfo [dict get $typeInfo $mode $serviceName $type] set typeDefInfo [GetServiceTypeDef $mode $serviceName $type] if {![llength $typeDefInfo]} { ## We failed to locate the type. try with the last known xns... set typeDefInfo [GetServiceTypeDef $mode $serviceName ${xns}:$type] } | > | 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 | set results {<** Circular Reference **>} ::log::log debug "Leaving [info level 0] with {$results}" return $results } else { set generatedTypes([list $mode $serviceName $type]) 1 } set type [string trimright $type {?}] # set typeDefInfo [dict get $typeInfo $mode $serviceName $type] set typeDefInfo [GetServiceTypeDef $mode $serviceName $type] if {![llength $typeDefInfo]} { ## We failed to locate the type. try with the last known xns... set typeDefInfo [GetServiceTypeDef $mode $serviceName ${xns}:$type] } |
︙ | ︙ | |||
4405 4406 4407 4408 4409 4410 4411 | } } set typeDefInfo [dict create definition [dict create $type $typeDefInfo]] } set partsList [dict keys [dict get $typeDefInfo definition]] ::log::log debug "\t partsList is {$partsList}" foreach partName $partsList { | | | 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 | } } set typeDefInfo [dict create definition [dict create $type $typeDefInfo]] } set partsList [dict keys [dict get $typeDefInfo definition]] ::log::log debug "\t partsList is {$partsList}" foreach partName $partsList { set partType [string trimright [dict get $typeDefInfo definition $partName type] {?}] set partXns $xns catch {set partXns [dict get $typeInfo $mode $serviceName $partType xns]} set typeInfoList [TypeInfo $mode $serviceName $partType] set isArray [lindex $typeInfoList end] ::log::log debug "\tpartName $partName partType $partType xns $xns typeInfoList $typeInfoList" switch -exact -- $typeInfoList { |
︙ | ︙ | |||
4545 4546 4547 4548 4549 4550 4551 | # Description : fetch via http following redirects. # May not be used as asynchronous call with -command option. # # Arguments : # url - target document url # args - additional argument list to http::geturl call # | | | 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 | # Description : fetch via http following redirects. # May not be used as asynchronous call with -command option. # # Arguments : # url - target document url # args - additional argument list to http::geturl call # # Returns : http package token of received data # # Side-Effects : Save final url in redirectArray to forward info to # procedure "processImport". # # Exception Conditions : None # # Pre-requisite Conditions : None |
︙ | ︙ | |||
4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 | set lastPos [string last / $initialUrl] set initialUrlDir [string range $initialUrl 0 [expr {$lastPos - 1}]] set lastPos [string last / $finalUrl] set finalUrlDir [string range $finalUrl 0 [expr {$lastPos - 1}]] ::log::log debug "initialUrlDir = $initialUrlDir, finalUrlDir = $finalUrlDir" set ::WS::Utils::redirectArray($initialUrlDir) $finalUrlDir } return $token } # http code announces redirect (3xx) array set meta [set ${token}(meta)] if {![info exist meta(Location)]} { ::log::log debug "Redirect http code without Location" return $token | > > | 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 | set lastPos [string last / $initialUrl] set initialUrlDir [string range $initialUrl 0 [expr {$lastPos - 1}]] set lastPos [string last / $finalUrl] set finalUrlDir [string range $finalUrl 0 [expr {$lastPos - 1}]] ::log::log debug "initialUrlDir = $initialUrlDir, finalUrlDir = $finalUrlDir" set ::WS::Utils::redirectArray($initialUrlDir) $finalUrlDir } return $token } elseif {![string match {20[1237]} $ncode]} { return $token } # http code announces redirect (3xx) array set meta [set ${token}(meta)] if {![info exist meta(Location)]} { ::log::log debug "Redirect http code without Location" return $token |
︙ | ︙ | |||
4679 4680 4681 4682 4683 4684 4685 | if {[lindex $args 0] eq "-bodyalwaysok"} { set bodyAlwaysOk [lindex $args 1] set args [lrange $args 2 end] } set token [eval ::WS::Utils::geturl_followRedirects $args] ::http::wait $token | | | | 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 | if {[lindex $args 0] eq "-bodyalwaysok"} { set bodyAlwaysOk [lindex $args 1] set args [lrange $args 2 end] } set token [eval ::WS::Utils::geturl_followRedirects $args] ::http::wait $token if {[::http::status $token] eq {ok}} { if {[::http::size $token] == 0} { ::log::log debug "\tHTTP error: no data" ::http::cleanup $token return -errorcode [list WS CLIENT NODATA [lindex $args 0]]\ -code error "HTTP failure socket closed" } if {$codeVar ne ""} { upvar 1 $codeVar ncode } set ncode [::http::ncode $token] set body [::http::data $token] ::http::cleanup $token if {$bodyAlwaysOk && ![string equal $body ""] || -1 != [lsearch $codeOkList $ncode] |
︙ | ︙ |
Changes to Wub.tcl.
︙ | ︙ | |||
44 45 46 47 48 49 50 | if {![llength [info command dict]]} { package require dict } package require uri package require base64 package require html | | | 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | if {![llength [info command dict]]} { package require dict } package require uri package require base64 package require html package provide WS::Wub 2.4.0 namespace eval ::WS::Wub { array set portInfo {} set portList [list] set forever {} |
︙ | ︙ |
Changes to WubServer.tcl.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # WSWub - Wub interface to WebServices package require Tcl 8.4 # WS::Utils usable here for dict? if {![llength [info command dict]]} { package require dict } package require WS::Server package require OO package require Direct package require Debug Debug off wsdl 10 | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | # WSWub - Wub interface to WebServices package require Tcl 8.4 # WS::Utils usable here for dict? if {![llength [info command dict]]} { package require dict } package require WS::Server package require OO package require Direct package require Debug Debug off wsdl 10 package provide WS::Wub 2.4.0 package provide Wsdl 2.4.0 class create Wsdl { method / {r args} { return [Http Ok $r [::WS::Server::generateInfo $service 0] text/html] } method /op {r args} { |
︙ | ︙ |
Changes to docs/Creating_a_Tcl_Web_Service.html.
︙ | ︙ | |||
165 166 167 168 169 170 171 172 173 174 175 176 177 178 | Defaults to "/service/" plus the service name -traceEnabled - Boolean to enable/disable trace being passed back in exception Defaults to "Y" -docFormat - Format of the documentation for operations ("text" or "html"). Defaults to "text" -stylesheet - The CSS stylesheet URL used in the HTML documentation </PRE> <p><b>Returns</b> : Nothing </p> <p><b>Side-Effects</b> : None </p> <p><b>Exception Conditions</b> : </p><PRE> <i>MISSREQARG</i> -- Missing required arguments </PRE> <p><b>Pre-requisite Conditions</b> : None </p> <HR> | > > > > > > | 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | Defaults to "/service/" plus the service name -traceEnabled - Boolean to enable/disable trace being passed back in exception Defaults to "Y" -docFormat - Format of the documentation for operations ("text" or "html"). Defaults to "text" -stylesheet - The CSS stylesheet URL used in the HTML documentation -errorCallback - Callback to be invoked in the event of an error being produced -verifyUserArgs - Boolean to enable/disable validating user supplied arguments Defaults to "N" -enforceRequired - Throw an error if a required field is not included in the response. Defaults to "N" </PRE> <p><b>Returns</b> : Nothing </p> <p><b>Side-Effects</b> : None </p> <p><b>Exception Conditions</b> : </p><PRE> <i>MISSREQARG</i> -- Missing required arguments </PRE> <p><b>Pre-requisite Conditions</b> : None </p> <HR> |
︙ | ︙ | |||
195 196 197 198 199 200 201 202 203 204 205 206 207 208 | typeName can be any simple or defined type. commentString is a quoted string describing the field <i>Documentation</i> -- HTML describing what this operation does <i>Body </i> -- The tcl code to be called when the operation is invoked. This code should return a dictionary with <OperationName>Result as a key and the operation's result as the value. </PRE> <p><b>Returns</b> : Nothing </p> <p><i>Side-Effects</i> : </p><PRE> A procedure named "<ServiceName>::<OperationName>" defined A type name with the name <OperationName>Result is defined. </PRE> <p><i>Exception Conditions</i> : None </p> <p><i>Pre-requisite Conditions</i> : ::WS::Server::Server must have been called for the ServiceName </p> | > > > > > > > > > > > | 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | typeName can be any simple or defined type. commentString is a quoted string describing the field <i>Documentation</i> -- HTML describing what this operation does <i>Body </i> -- The tcl code to be called when the operation is invoked. This code should return a dictionary with <OperationName>Result as a key and the operation's result as the value. </PRE> Available simple types are: <UL><LI>anyType, string, boolean, decimal, float, double, duration, dateTime, time, date, gYearMonth, gYear, gMonthDay, gDay, gMonth, hexBinary, base64Binary, anyURI, QName, NOTATION, normalizedString, token, language, NMTOKEN, NMTOKENS, Name, NCName, ID, IDREF, IDREFS, ENTITY, ENTITIES, integer, nonPositiveInteger, negativeInteger, long, int, short, byte, nonNegativeInteger, unsignedLong, unsignedInt, unsignedShort, unsignedByte, positiveInteger</LI></UL> The <em>typeName</em> may contain the following suffixes: <UL> <LI><em>()</em> : type is an array</LI> <LI><em>?</em> : type is an optional parameter</LI> </UL> <p><b>Returns</b> : Nothing </p> <p><i>Side-Effects</i> : </p><PRE> A procedure named "<ServiceName>::<OperationName>" defined A type name with the name <OperationName>Result is defined. </PRE> <p><i>Exception Conditions</i> : None </p> <p><i>Pre-requisite Conditions</i> : ::WS::Server::Server must have been called for the ServiceName </p> |
︙ | ︙ |
Added docs/Rest_flavor_service_response.html.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | <HTML lang=en dir=ltr xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"> <HEAD> <TITLE>Rest-flavor service reply</TITLE> <link rel="stylesheet" href="style.css" type="text/css" media="screen"> </HEAD> <BODY> <H1 class=firstHeading>Rest-flavor service reply</H1> <HR> <TABLE class=toc id=toc> <TR> <TD> <H2>Contents</H2></DIV> <UL> <LI class=toclevel-1><A href="#Overview"><SPAN class=tocnumber>1</SPAN> <SPAN class=toctext>Overview</SPAN></A> <LI class=toclevel-1><A href="#Rivet_Example"><SPAN class=tocnumber>2</SPAN> <SPAN class=toctext>Rivet example</SPAN></A> </UL></TD></TR></TBODY></TABLE> <P> </P> <A name=Overview></A> <H2>Overview </H2> <P>Since TCLWS 2.4, it is possible to return a response in <em>REST style</em>. This means, that a JSON reply is returned instead of an XML document.</P> <P>Our use case has only required us to accept FORM arguments and return JSON responses for everything, so we haven't implemented logic to parse any input arguments that are passed in as JSON serialized data, but this might be an area of future exploration for someone.</P> <A name=Rivet_Example></A> <H2>Rivet Example</H2> <P>Here's a bit of code showing how we initially start up this mode in Apache Rivet, which is actually pretty similar to how you'd use tclws in SOAP mode from Apache Rivet:</P> <PRE> # Capture the info from the request into an array. load_headers hdrArray set sock [pid]; # an arbitrary value array unset ::Httpd$sock # Prepare the CGI style arguments into a list load_response formArray set opname $formArray(call) unset formArray(call) set queryarg [list $opname [array get formArray]] # Invoke the the method array set ::Httpd$sock [list query $queryarg ipaddr [env REMOTE_ADDR] headerlist [array get hdrArray]] # Invoke the method in REST mode. set result [catch {::WS::Server::callOperation $svcname $sock -rest} error] array unset ::Httpd$sock if {$result} { headers numeric 500 puts "Operation failed: $error" abort_page } </PRE> </BODY> </HTML> |
Changes to docs/index.html.
︙ | ︙ | |||
19 20 21 22 23 24 25 | currently works only with TclHttpd or embedded into an application. The server side provides all services as document/literal over HTTP Soap transport. Documentation for the package, including examples can be found here. </p> <UL> | | | | > | | | > | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | currently works only with TclHttpd or embedded into an application. The server side provides all services as document/literal over HTTP Soap transport. Documentation for the package, including examples can be found here. </p> <UL> <LI> <A HREF="Calling_a_Web_Service.html">Calling a Web Service from Tcl</A></LI> <LI> <A HREF="Creating_a_Tcl_Web_Service.html">Creating a Tcl Web Service</A></LI> <LI> <A HREF="Creating_a_Web_Service_Type.html">Creating a Web Service Type</A></LI> <LI> <A HREF="Rest_flavor_service_response.html">REST flavor service response</A></LI> <LI> <A HREF="Dictionary_Representation_of_XML_Arrays.html">Dictionary Representation of XML Arrays</A></LI> <LI> <A HREF="Using_Options.html">Using Web Service Options</A></LI> <LI> <A HREF="Embedded_Web_Service.html">Embeding a Web Service into an application</A></LI> <LI> <A HREF="Tcl_Web_Service_Example.html">Tcl Web Service Example</A></LI> <LI> <A HREF="Tcl_Web_Service_Math_Example.html">Tcl Web Service Math Example</A></LI> </UL> <p> The client is known to work with #C and Java based Web Services (your mileage may very). </p> |
︙ | ︙ | |||
66 67 68 69 70 71 72 73 74 75 76 | </li><li> <a href="http://www.tdom.org/">tdom 0.8.1</a> <li> dict (if tcl8.4 is used)</a> </li><li> <a href="http://tls.sf.net/">tls</a> (client and embedded server) </li><li> log from <a href="http://tcllib.sf.net/">TclLib</a> </li><li> uri from <a href="http://tcllib.sf.net/">TclLib</a> </li><li> struct::set from <a href="http://tcllib.sf.net/">TclLib</a> </li><li> http from <a href="http://tcl.sf.net/">Tcl</a> itself </li></ul> <p> | > | | | 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | </li><li> <a href="http://www.tdom.org/">tdom 0.8.1</a> <li> dict (if tcl8.4 is used)</a> </li><li> <a href="http://tls.sf.net/">tls</a> (client and embedded server) </li><li> log from <a href="http://tcllib.sf.net/">TclLib</a> </li><li> uri from <a href="http://tcllib.sf.net/">TclLib</a> </li><li> struct::set from <a href="http://tcllib.sf.net/">TclLib</a> </li><li> http from <a href="http://tcl.sf.net/">Tcl</a> itself </li><li> yajl-tcl from <a href="https://github.com/flightaware/yajl-tcl">flightaware github</a> (only for rest-flavour requests) </li></ul> <p> If you are running the TclHttpd on Windows, it is highly recommended that you use the iocpsock extension. </p> <p> The following packages are additionally used in Embedded Server mode: </p><ul> <li> base64 from <a href="http://tcllib.sf.net/">TclLib</a> (also channel server) </li><li> html from <a href="http://tcllib.sf.net/">TclLib</a> (also channel server) </li><li> ncgi from <a href="http://tcllib.sf.net/">TclLib</a> </li><li> fileutil from <a href="http://tcllib.sf.net/">TclLib</a> </li></ul> </BODY> </HTML> |
Changes to pkgIndex.tcl.
1 | # Tcl package index file, version 1.1 | | > | | | | | | | < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | # Tcl package index file, version 1.1 # This file is generated by the "pkg_mkIndex -direct" command # and sourced either when an application starts up or # by a "package unknown" script. It invokes the # "package ifneeded" command to set up package-related # information so that packages will be loaded automatically # in response to "package require" commands. When this # script is sourced, the variable $dir must contain the # full path name of this file's directory. package ifneeded WS::AOLserver 2.4.0 [list source [file join $dir AOLserver.tcl]] package ifneeded WS::Channel 2.4.0 [list source [file join $dir ChannelServer.tcl]] package ifneeded WS::Client 2.4.3 [list source [file join $dir ClientSide.tcl]] package ifneeded WS::Embeded 2.4.0 [list source [file join $dir Embedded.tcl]] package ifneeded WS::Server 2.4.0 [list source [file join $dir ServerSide.tcl]] package ifneeded WS::Utils 2.4.0 [list source [file join $dir Utilities.tcl]] package ifneeded WS::Wub 2.4.0 [list source [file join $dir WubServer.tcl]] package ifneeded Wsdl 2.4.0 [list source [file join $dir WubServer.tcl]] |