Ticket UUID: | dcce437d7aa5e64a150dc6b44a52f0101af783d9 | ||
Title: | Allow inline namespaces in WSDL | ||
Status: | Closed | Type: | Feature_Request |
Severity: | Important | Priority: | Immediate |
Subsystem: | Client_Side | Resolution: | Fixed |
Assigned to: | unassigned | ||
Last Modified: | 2017-12-04 20:53:13 | ||
Version Found In: | |||
Description & Comments: | |||
When namespaces are only defined inline at elements, e.g:
<xs:element xmlns:q1="myNS" type="q1:MessageQ1"/> the WSDL parser throws this error: Could not find tns 'q1' in .... When the namespace definitions are copied to to the <wsdl:definitions> tag, the WSDL parses correctly. oehhar added on 2017-01-09 08:59:26 UTC: It is a simple but not beautiful change. Obviously, one may not select on the attribute "xmlns:*" by xpath. For that, all "xs:element" nodes are checked for this attribute. It would be ideal to switch this functionality on and off. The patch is: 1039c1039,1065 < --- > foreach itemList [$wsdlNode attributes xmlns:*] { > set ns [lindex $itemList 0] > set url [$wsdlNode getAttribute xmlns:$ns] > if {[dict exists $nsDict url $url]} { > set tns [dict get $nsDict url $url] > } else { > ## > ## Check for hardcoded namespaces > ## > switch -exact -- $url { > http://schemas.xmlsoap.org/wsdl/ { > set tns w > } > http://schemas.xmlsoap.org/wsdl/soap/ { > set tns d > } > http://www.w3.org/2001/XMLSchema { > set tns xs > } > default { > set tns tns[incr nsCount] > } > } > dict set nsDict url $url $tns > } > dict set nsDict tns $ns $tns > } 1044,1078d1069 < } < < set elems $wsdlNode < set elems [concat $elems [$wsdlDoc selectNodes {//xs:element}]] < < foreach elemNode $elems { < set xmlnsAttributes [$elemNode attributes xmlns:*] < < foreach itemList $xmlnsAttributes { < set ns [lindex $itemList 0] < set url [$elemNode getAttribute xmlns:$ns] < if {[dict exists $nsDict url $url]} { < set tns [dict get $nsDict url $url] < } else { < ## < ## Check for hardcoded namespaces < ## < switch -exact -- $url { < http://schemas.xmlsoap.org/wsdl/ { < set tns w < } < http://schemas.xmlsoap.org/wsdl/soap/ { < set tns d < } < http://www.w3.org/2001/XMLSchema { < set tns xs < } < default { < set tns tns[incr nsCount] < } < } < dict set nsDict url $url $tns < } < dict set nsDict tns $ns $tns < } --- I asked Rolf Ade, if he sees a solution without the loop. oehhar added on 2017-01-09 09:00:22 UTC: 1039c1039,1065 < --- > foreach itemList [$wsdlNode attributes xmlns:*] { > set ns [lindex $itemList 0] > set url [$wsdlNode getAttribute xmlns:$ns] > if {[dict exists $nsDict url $url]} { > set tns [dict get $nsDict url $url] > } else { > ## > ## Check for hardcoded namespaces > ## > switch -exact -- $url { > http://schemas.xmlsoap.org/wsdl/ { > set tns w > } > http://schemas.xmlsoap.org/wsdl/soap/ { > set tns d > } > http://www.w3.org/2001/XMLSchema { > set tns xs > } > default { > set tns tns[incr nsCount] > } > } > dict set nsDict url $url $tns > } > dict set nsDict tns $ns $tns > } 1044,1078d1069 < } < < set elems $wsdlNode < set elems [concat $elems [$wsdlDoc selectNodes {//xs:element}]] < < foreach elemNode $elems { < set xmlnsAttributes [$elemNode attributes xmlns:*] < < foreach itemList $xmlnsAttributes { < set ns [lindex $itemList 0] < set url [$elemNode getAttribute xmlns:$ns] < if {[dict exists $nsDict url $url]} { < set tns [dict get $nsDict url $url] < } else { < ## < ## Check for hardcoded namespaces < ## < switch -exact -- $url { < http://schemas.xmlsoap.org/wsdl/ { < set tns w < } < http://schemas.xmlsoap.org/wsdl/soap/ { < set tns d < } < http://www.w3.org/2001/XMLSchema { < set tns xs < } < default { < set tns tns[incr nsCount] < } < } < dict set nsDict url $url $tns < } < dict set nsDict tns $ns $tns < } gwlester added on 2017-04-05 21:37:53 UTC: If it is backwardly compatible, then ya'll should apply it to the main branch. oehhar added on 2017-04-07 06:58:39 UTC: The patch is now a branch starting with commit [57a60e547b]. I did not merge it, because:
To your question: I have no idea if this is backward compatible or not. Thank you, Harald oehhar added on 2017-11-03 16:07:01 UTC: I made some tests and found the patch useful. For all my tests, it was compatible to the prior solution, so IMHO no switch for activation required. Rolf had no better solution compared to the loop. IMHO a performance decrease in WSDL parsing is o.k., as WSDL is normally only parsed once per Web-Service. Thanks to Wolfgang for the patch ! Harald oehhar added on 2017-11-06 07:53:41 UTC: Within XML, namespace prefixes may be nested and reused: https://stackoverflow.com/questions/41774652/can-you-reuse-the-same-namespace-in-an-xml-document What about the situation, that a namespace prefix is reused in an element node but with a different URL: <wsdl:definitions xmlns:q1="URI1" ...> <xs:element xmlns:q1="URI2" type="q1:MessageQ1"/> As TCLWS currently holds a global namespace table, this would result in a wrong assignment within TCLWS. As a consequence, I want to add a test if the namespace prefix is reused and just error out for instance. What do you think ? Harald oehhar added on 2017-11-06 08:24:39 UTC: oehhar added on 2017-12-04 20:53:13 UTC: |