Menu

#227 Invalid namespace resolution in WSDLCatalogerEngine

3.1
open
5
2007-09-11
2007-09-11
No

The WSDL cataloging service fails on the attached stockquoteservice.wsdl with the following exception:

org.freebxml.omar.common.exceptions.CatalogingException: The following required element is missing from file null: tns:StockQuotePortType
at org.freebxml.omar.server.profile.ws.wsdl.cataloger.WSDLCatalogerEngine.processBinding(WSDLCatalogerEngine.java:1133)
at org.freebxml.omar.server.profile.ws.wsdl.cataloger.WSDLCatalogerEngine.processPort(WSDLCatalogerEngine.java:1044)
at org.freebxml.omar.server.profile.ws.wsdl.cataloger.WSDLCatalogerEngine.processService(WSDLCatalogerEngine.java:965)

The problem is related to the fact that stockquoteservice.wsdl imports stockquote.wsdl and that both files have a namespace declaration for prefix "tns" but with different namespace URIs. This is valid but confuses the WSDLCatalogerEngine.

The problem can be traced back to the fact that WSDLCatalogerEngine#createQName (which is used by WSDLCatalogerEngine#resolvePortType) always resolves qualified names in the scope of the root WSDL document.
In this case, this causes tns:StockQuotePortType in the imported WSDL to be resolved to {http://example.com/stockquote/service}StockQuotePortType instead of {http://example.com/stockquote/definitions}StockQuotePortType.

I believe that in the context of this bug, the following method (which is used by createQName) in WSDLDocument also needs to be reviewed:

public String getNamespaceURI(String prefix) {
String namespaceURI = (String)namespaceLookup.get(prefix);
if (namespaceURI == null) {
namespaceURI = getNamespaceURIFromImport(prefix);
}
return namespaceURI;
}

Obviously it tries first to resolve the prefix in the current document and if no namespace declaration is found, recursively tries to resolve the prefix using the namespace declarations in the imported documents. This code seems to be based on the wrong assumption that namespace declarations in imported documents have impact in the scope of the importing document.

In fact, this particular behaviour of the getNamespaceURI method partially compensates the scope problem in the createQName method, except where there is a collision between prefixes in the importing and imported document.

Note: to reproduce the problem using the attached files, you will need to correct the location attributes of the various import elements.

Discussion

  • Andreas Veithen

    Andreas Veithen - 2007-09-11

    stockquoteservice.wsdl (Root WSDL)

     
  • Andreas Veithen

    Andreas Veithen - 2007-09-11

    stockquote.wsdl (Imported WSDL)

     
  • Andreas Veithen

    Andreas Veithen - 2007-09-11

    Logged In: YES
    user_id=423887
    Originator: YES

    File Added: stockquote.wsdl

     
  • Andreas Veithen

    Andreas Veithen - 2007-09-11

    Logged In: YES
    user_id=423887
    Originator: YES

    File Added: stockquote.xsd

     
  • Andreas Veithen

    Andreas Veithen - 2007-09-11
     

Log in to post a comment.