Problem parsing a wsdl
by Alastair Irving
Hi
I'm very new to suds, so appologise in advance if I'm missing something
obvious. I'm running version 0.3.7 under Windows with python 2.6.
I tried running the following:
from suds.client import Client
c=Client('https://api.betfair.com/global/v3/BFGlobalService.wsdl')
I got the following traceback:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build\bdist.win32\egg\suds\client.py", line 109, in __init__
File "build\bdist.win32\egg\suds\wsdl.py", line 194, in __init__
File "build\bdist.win32\egg\suds\wsdl.py", line 255, in build_schema
File "build\bdist.win32\egg\suds\xsd\schema.py", line 90, in load
File "build\bdist.win32\egg\suds\xsd\schema.py", line 277, in open_imports
File "build\bdist.win32\egg\suds\xsd\sxbasic.py", line 608, in open
File "build\bdist.win32\egg\suds\xsd\sxbasic.py", line 626, in download
File "build\bdist.win32\egg\suds\sax\parser.py", line 134, in parse
File "c:\Python26\lib\xml\sax\expatreader.py", line 107, in parse
xmlreader.IncrementalParser.parse(self, source)
File "c:\Python26\lib\xml\sax\xmlreader.py", line 123, in parse
self.feed(buffer)
File "c:\Python26\lib\xml\sax\expatreader.py", line 211, in feed
self._err_handler.fatalError(exc)
File "c:\Python26\lib\xml\sax\handler.py", line 38, in fatalError
raise exception
xml.sax._exceptions.SAXParseException:
c:\docume~1\alasta~1\locals~1\temp\suds\s
uds-649682136.http:10:2: mismatched tag
The contents of the file refference by the last line are:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd">
<!-- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd"> -->
<HTML>
<HEAD>
<META HTTP-EQUIV="Refresh" CONTENT="0.1">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
<TITLE></TITLE>
</HEAD>
<BODY><P></BODY>
</HTML>
Something's clearly gone wrong as it surely shouldn't be fetching HTML
files. However I think its unlikely that there would be a problem with
the wsdl so I suspect its either a problem with suds or with my usage of it.
Any help will be much appreciated.
Alastair Irving
14 years, 6 months
print client does not show types of results of methods
by Rod Montgomery
From browsing the Suds source code, I get the impression that Suds does not even use the type info specified in the WSDL
files for the results of methods. It just parses whatever XML comes back from the service, converts it to a corresponding
Pythonic data structure, and returns that.
I guess that's ok, except that it means that, to understand what comes back, I have to dig through the WSDL files.
Do any other SOAP clients -- Pythonic or not -- actually use the WSDL-specified method-result types? For what?
For error detection, how useful would it be to have a "result type does not match type declared in WSDL files" exception
thrown at the point where the result comes back, rather than maybe have some random no-such-member exception(s) thrown while
trying to process the result?
How annoying would it be, to have a "result type does not match..." exception thrown, when the mismatch would not have
affected the proper operation of the client code anyway?
I wonder whether I could make Suds just remember the declared type of each method result, and display it in the "print
client" output, purely as human-readable documentation? Maybe just tack another element onto the tuple that represents each
method in the .ports member of the suds.servicedefinition.ServiceDefinition class, and pick it up for display in the
description member function of that class?
14 years, 6 months
Does servicedefinition.py class ServiceDefinition method findport have a bad comparison?
by Rod Montgomery
In file servicedefinition.py, the findport method of class ServiceDefinition reads as follows:
def findport(self, port):
"""
Find and return a port tuple for the specified port.
Created and added when not found.
@param port: A port.
@type port: I{service.Port}
@return: A port tuple.
@rtype: (port, [method])
"""
for p in self.ports:
if p[0] == p: return p
p = (port, [])
self.ports.append(p)
return p
Should not the comparison be if p[0] == port rather than if p[0] == p ?
I don't quite see how to trigger the failure. It would have to be a situation in which the same port had to be looked up a
second time. The only invocation of the findport method is from the addports method immediately above it, and the only
invocation of addports is from the __init__ method for the class. I think that means it would take a second appearance of
the same port in the WSDL to trigger a failure.
Maybe a situation in which some methods for a port are defined in one WSDL file, and others in a second WSDL file?
14 years, 6 months