Hi,
myClient = suds.client.Client(wsdl, transport=HackTransport(fileFromU2), etc)
On Wednesday 06 October 2010, Janet Valbuena elucidated thus:
I would try to download the file with a quick urllib2 script and see> Hi
>
> I'm new to suds (have just downloaded it after getting frustrated
> with SOAPpy).
>
> I'm trying to connect to a WSDL which requires basic HTTP
> authentication. I have been able to connect to it correctly using PHP
> but I need to use Python.
>
>
> This is my code:
>
> #!/usr/bin/python
>
> Username = "user"
> Password = "pass123"
> from suds.transport.http import HttpAuthenticated
> t = HttpAuthenticated(username=Username, password=Password)
>
> # WSDL is only available in internal network
> WSDL = "http://localhost:18080/external/services/DomService?wsdl"
> from suds.client import Client
> client = Client(WSDL, transport=t)
>
>
>
>
> And this is the error it returns:
>
> Traceback (most recent call last):
> File "./wsdltest.py", line 25, in <module>
> client = Client(wsdl, transport=t)
> File "build/bdist.linux-i686/egg/suds/client.py", line 112, in
> __init__ File "build/bdist.linux-i686/egg/suds/reader.py", line 152,
> in open File "build/bdist.linux-i686/egg/suds/wsdl.py", line 136, in
> __init__ File "build/bdist.linux-i686/egg/suds/reader.py", line 79,
> in open File "build/bdist.linux-i686/egg/suds/reader.py", line 101,
> in download File "build/bdist.linux-i686/egg/suds/sax/parser.py",
> line 136, in parse File "/usr/lib/python2.5/xml/sax/expatreader.py",
> line 107, in parse xmlreader.IncrementalParser.parse(self, source)
> File "/usr/lib/python2.5/xml/sax/xmlreader.py", line 125, in parse
> self.close()
> File "/usr/lib/python2.5/xml/sax/expatreader.py", line 217, in
> close self.feed("", isFinal = 1)
> File "/usr/lib/python2.5/xml/sax/expatreader.py", line 211, in feed
> self._err_handler.fatalError(exc)
> File "/usr/lib/python2.5/xml/sax/handler.py", line 38, in
> fatalError raise exception
> xml.sax._exceptions.SAXParseException: <unknown>:1:0: no element
> found
what you get. The error is not in the connect (that would raise its
own exception) but in trying to parse what *is* being downloaded.
Something like:
import urllib2
auth_handler = urllib2.HTTPBasicAuthHandler()
auth_handler.add_password(realm='name_of_your_realm',
uri='your_url_without_the_file_name',
user=User,
passwd=Password)
opener = urllib2.build_opener(auth_handler)
urllib2.install_opener(opener)
print urllib2.open(WSDL).read()
j
--
Joshua Kugler
Part-Time System Admin/Programmer
http://www.eeinternet.com - Fairbanks, AK
PGP Key: http://pgp.mit.edu/ ID 0x73B13B6A
_______________________________________________
suds mailing list
suds@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/suds