python SUDS library

Diez B. Roggisch deets at nospam.web.de
Thu Mar 4 22:43:12 CET 2010


Am 04.03.10 06:23, schrieb yamamoto:
> Hi,
> I tried to make a simple script with SUD library for caching torrent
> files. it doenst work!
>
> [versions]
> suds: 0.4, python: 2.6.4
>
> [code]
> from suds.client import Client
> import base64
>
> path = 'sample.torrent'
> doc = open(path, 'rb').read()
> encoded_doc = base64.b64encode(doc)
> url = 'http://torrage.com/api/torrage.wsdl'
> client = Client(url, cache=None)
> print client
> hash = client.service.cacheTorrent(encoded_doc)
> print hash
>
> [result]
>
> Suds ( https://fedorahosted.org/suds/ )  version: 0.4 (beta)  build:
> R663-20100303
>
> Service ( CacheService ) tns="urn:Torrage"
>     Prefixes (0)
>     Ports (1):
>        (CachePort)
>           Methods (1):
>              cacheTorrent(xs:string torrent, )
>           Types (0):
>
> Traceback (most recent call last):
>    File "C:\Documents and Settings\yamamoto\workspace\python\console
> \extract.py", line 13, in<module>
>      result = client.service.cacheTorrent(encoded_doc)
>    File "C:\Python26\lib\site-packages\suds\client.py", line 539, in
> __call__
>      return client.invoke(args, kwargs)
>    File "C:\Python26\lib\site-packages\suds\client.py", line 598, in
> invoke
>      result = self.send(msg)
>    File "C:\Python26\lib\site-packages\suds\client.py", line 627, in
> send
>      result = self.succeeded(binding, reply.message)
>    File "C:\Python26\lib\site-packages\suds\client.py", line 659, in
> succeeded
>      r, p = binding.get_reply(self.method, reply)
>    File "C:\Python26\lib\site-packages\suds\bindings\binding.py", line
> 143, in get_reply
>      replyroot = sax.parse(string=reply)
>    File "C:\Python26\lib\site-packages\suds\sax\parser.py", line 136,
> in parse
>      sax.parse(source)
>    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:<unknown>:2:0: junk after
> document element
>
>
> this is a php code provided by torrage
> <?
>          $client = new SoapClient("http://torrage.com/api/
> torrage.wsdl");
>          $infoHash = $client-
>> cacheTorrent(base64_encode(file_get_contents("my.torrent")));
> ?>
>
> any suggestions?

Looks like the XML is malformed. Can you post it? You can insert 
print-statements into the library to do so, eg in line 143 of 
suds.bindings.binding.

Diez

Diez




More information about the Python-list mailing list