View Ticket
Not logged in
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:
Wolfgang (Thanks !) sent a patch by private E-Mail with the comment:

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:
Is the patch not backwardly compatible?

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:
Thank you, Gerald, for the comment.

The patch is now a branch starting with commit [57a60e547b].

I did not merge it, because:

  • I do not understand what it does
  • the remark "it is not beautiful" suggested that there might be a better solution
  • the remark "ideally it should be switchable" suggested that there is work to do

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:
Merged to trunk by commit [1915e65746] and closed ticket.

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:
I had some thoughts about the namespace prefix situation.

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:
A test for namespace prefix reuse was introduced with commit [fb182ca3fc]


oehhar added on 2017-12-04 20:53:13 UTC:
Functionality is now switchable by commit [4bc013299a]


Attachments: