kartagis / pysimplesoap

Automatically exported from code.google.com/p/pysimplesoap
0 stars 0 forks source link

Fails to load WSDL provided by BEA WebLogic Server #19

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. from pysimplesoap.client import SoapClient
2. SoapClient('http://www.destin8.co.uk/ISLInterface/ISLInterface?WSDL')

What is the expected output? What do you see instead?

The SoapClient instance should be initialised from the WSDL. It instead throws 
the following exception;

  ...
  File "./aisarchive.py", line 52, in _create_client
    result = SoapClient(wsdl='%s?WSDL' % self._url, trace=True)
  File "/export/home/henry/code/lib/pysimplesoap/pysimplesoap/client.py", line 68, in __init__
    self.services = wsdl and self.wsdl(wsdl, debug=trace, cache=cache)
  File "/export/home/henry/code/lib/pysimplesoap/pysimplesoap/client.py", line 461, in wsdl
    preprocess_schema(schema)
  File "/export/home/henry/code/lib/pysimplesoap/pysimplesoap/client.py", line 434, in preprocess_schema
    process_element(element_name, children)
  File "/export/home/henry/code/lib/pysimplesoap/pysimplesoap/client.py", line 372, in process_element
    uri = ns and e.get_namespace_uri(ns) or xsd_uri
  File "/export/home/henry/code/lib/pysimplesoap/pysimplesoap/simplexml.py", line 182, in get_namespace_uri
    v = self.__document.documentElement.attributes['xmlns:%s' % ns]
  File "/usr/local/lib/python2.6/xml/dom/minidom.py", line 530, in __getitem__
    return self._attrs[attname_or_tuple]
KeyError: u'xmlns:xsd'

What version of the product are you using? On what operating system?

pysimplesoap-1.02c.zip
BEA WebLogic Server 8.1

Please provide any additional information below.

The problem is the 'xsd' namespace found under schema elements.

This isn't the server I'm using; the WSDL is from a server I found online 
(http://www.google.com/search?q=%22For+a+formal+definition,+please+review+the+Se
rvice+Description%22+%22BEA+WebLogic+Server+8.1%22).

Original issue reported on code.google.com by misc%hl....@gtempaccount.com on 5 Jan 2011 at 3:47

GoogleCodeExporter commented 8 years ago
The problem is that SimpleXMLElement only looks in the document element for 
namespaces; it can be in the element itself, or any ancestor element. Here is a 
simple patch that fixes the issue for me.

--- a/pysimplesoap/simplexml.py
+++ b/pysimplesoap/simplexml.py
@@ -179,8 +179,14 @@ class SimpleXMLElement(object):

     def get_namespace_uri(self, ns):
         "Return the namespace uri for a prefix"
-        v = self.__document.documentElement.attributes['xmlns:%s' % ns]
-        return v.value
+        element = self._element
+        while element is not None:
+            try:
+                return element.attributes['xmlns:%s' % ns].value
+            except KeyError:
+                element = element.parentNode
+                assert element is not None
+        assert False, "Failed to find namespace '%s'!" % ns

     def attributes(self):
         "Return a dict of attributes for this tag"

Original comment by misc%hl....@gtempaccount.com on 5 Jan 2011 at 4:15

GoogleCodeExporter commented 8 years ago
This issue was closed by revision 25757649fb06.

Original comment by reingart@gmail.com on 23 Nov 2011 at 7:04

GoogleCodeExporter commented 8 years ago
Fixed in 25757649fb06

Original comment by reingart@gmail.com on 23 Nov 2011 at 7:04