Check-in [fb182ca3fc]
Not logged in
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Added check (for nested namespace prefix case), that a namespace prefix is not reused for another URI. See Ticket [dcce437d7a]
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: fb182ca3fc147bf0774dfb05eb2b1f504f8350564dafc22df351df6699bd2f25
User & Date: oehhar 2017-11-06 08:20:48
References
2017-11-06 08:24 Ticket [dcce437d7a] Allow inline namespaces in WSDL status still Closed with 1 other change artifact: b96ece5613 user: oehhar
Context
2017-11-14 10:14
Reworked the webservice call option list documentation (so I understand it better) check-in: 63108ec92f user: oehhar tags: trunk
2017-11-06 08:20
Added check (for nested namespace prefix case), that a namespace prefix is not reused for another URI. See Ticket [dcce437d7a] check-in: fb182ca3fc user: oehhar tags: trunk
2017-11-03 16:00
Search namespace prefix also in element nodes and not only in definition node of wsdl file. Patch by by Wolfgang Winkler. Ticket [dcce437d7a] check-in: 1915e65746 user: oehhar tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ClientSide.tcl.

   985    985   # Maintenance History - as this file is modified, please be sure that you
   986    986   #                       update this segment of the file header block by
   987    987   #                       adding a complete entry at the bottom of the list.
   988    988   #
   989    989   # Version     Date     Programmer   Comments / Changes / Reasons
   990    990   # -------  ----------  ----------   -------------------------------------------
   991    991   #       1  07/06/2006  G.Lester     Initial version
   992         -# 2.4.4    2017-11-03  H. Oehlmann  Included ticket [dcce437d7a] with
          992  +# 2.4.4    2017-11-03  H.Oehlmann  Included ticket [dcce437d7a] with
   993    993   #                                   solution by Wolfgang Winkler:
   994    994   #                                   Search namespace prfix also in element
   995    995   #                                   nodes and not only in definition node
   996    996   #                                   of wsdl file.
          997  +# 2.4.4    2017-11-06  H.Oehlmann   Added check (for nested namespace prefix
          998  +#                                   case), that a namespace prefix is not
          999  +#                                   reused for another URI.
   997   1000   #
   998   1001   #
   999   1002   ###########################################################################
  1000   1003   proc ::WS::Client::ParseWsdl {wsdlXML args} {
  1001   1004       variable currentBaseUrl
  1002   1005       variable serviceArr
  1003   1006   
................................................................................
  1039   1042       #   not to clash with the wsdl prefix in <ns>
  1040   1043       #   Predefined:
  1041   1044       #   - tns1 : targetNamespace
  1042   1045       #   - w: http://schemas.xmlsoap.org/wsdl/
  1043   1046       #   - d: http://schemas.xmlsoap.org/wsdl/soap/
  1044   1047       #   - xs: http://www.w3.org/2001/XMLSchema
  1045   1048       #
  1046         -    # The top node <wsdl:definitions
         1049  +    # The top node
         1050  +    # <wsdl:definitions
  1047   1051       #   targetNamespace="http://www.webserviceX.NET/">
  1048   1052       #   xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/ ...>
  1049   1053       # contains the target namespace and all namespace definitions
  1050   1054       dict set nsDict url $targetNs tns$nsCount
  1051   1055   
  1052   1056       $wsdlDoc selectNodesNamespaces {
  1053   1057           w http://schemas.xmlsoap.org/wsdl/
................................................................................
  1055   1059           xs http://www.w3.org/2001/XMLSchema
  1056   1060       }
  1057   1061   
  1058   1062       ##
  1059   1063       ## loop over the top definitions node and all elements nodes
  1060   1064       ##
  1061   1065       # Element nodes may declare namespaces inline like:
  1062         -    # <xs:element xmlns:q1="myNS" type="q1:MessageQ1"/>
         1066  +    # <xs:element xmlns:q1="myURI" type="q1:MessageQ1"/>
  1063   1067       # ticket [dcce437d7a]
  1064   1068       foreach elemNode [linsert [$wsdlDoc selectNodes {//xs:element}] 0 $wsdlNode] {
  1065   1069           # Get list of xmlns attributes
  1066   1070           # This list looks for the example like: {{q1 q1 {}} ... }
  1067   1071           set xmlnsAttributes [$elemNode attributes xmlns:*] 
  1068   1072           # Loop over found namespaces
  1069   1073           foreach itemList $xmlnsAttributes {
  1070   1074               set ns [lindex $itemList 0]
  1071   1075               set url [$elemNode getAttribute xmlns:$ns]
         1076  +
  1072   1077               if {[dict exists $nsDict url $url]} {
  1073   1078                   set tns [dict get $nsDict url $url]
  1074   1079               } else {
  1075   1080                   ##
  1076   1081                   ## Check for hardcoded namespaces
  1077   1082                   ##
  1078   1083                   switch -exact -- $url {
................................................................................
  1087   1092                       }
  1088   1093                       default {
  1089   1094                           set tns tns[incr nsCount]
  1090   1095                       }
  1091   1096                   }
  1092   1097                   dict set nsDict url $url $tns
  1093   1098               }
         1099  +            ##
         1100  +            ## Check if same namespace prefix was already assigned to a
         1101  +            ## different URL
         1102  +            ##
         1103  +            # This may happen, if the element namespace prefix overwrites
         1104  +            # a global one, like
         1105  +            # <wsdl:definitions xmlns:q1="URI1" ...>
         1106  +            #   <xs:element xmlns:q1="URI2" type="q1:MessageQ1"/>
         1107  +            if { [dict exists $nsDict tns $ns] && $tns ne [dict get $nsDict tns $ns] } {
         1108  +                ::log::log debug "Namespace prefix '$ns' with different URI '$url': $nsDict"
         1109  +                return \
         1110  +                    -code error \
         1111  +                    -errorcode [list WS CLIENT AMBIGNSPREFIX] \
         1112  +                    "element namespace prefix '$ns' used again for different URI '$url'.\
         1113  +                    Sorry, this is a current implementation limitation of TCLWS."
         1114  +            }
  1094   1115               dict set nsDict tns $ns $tns
  1095   1116           }
  1096   1117       }
  1097   1118   
  1098   1119       if {[info exists currentBaseUrl]} {
  1099   1120           set url $currentBaseUrl
  1100   1121       } else {
................................................................................
  2024   2045       # Possibility (2) "OutName" WSDL example:
  2025   2046       # <wsdl:portType...><wsdl:operation...>
  2026   2047       #   <wsdl:output name="{OutName}" message="tns:{OutMsgName}" />
  2027   2048       # This possibility is requested by ticket [21f41e22bc]
  2028   2049       #
  2029   2050       # Possibility (3) default name "{OperationName}Result" WSDL example:
  2030   2051       # <wsdl:portType...><wsdl:operation name="{OperationName}">
  2031         -    #   <wsdl:output message="tns:{OutMsgName}" /> *** no name tag ***
         2052  +    #   <wsdl:output message="tns:{OutMsgName}" -> *** no name tag ***
  2032   2053       #
  2033   2054       # Possibility (4) was not found in wsdl 1.0 standard but was used as only
  2034   2055       # solution by TCLWS prior to 2.4.2.
  2035   2056       # The following sketch shows the location of the local output type name
  2036   2057       # "OutTypeName" in a WSDL file:
  2037   2058       # -> In WSDL portType output message name
  2038   2059       # <wsdl:portType...><wsdl:operation...>