python SUDS library

Y

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-[QUOTE]
cacheTorrent(base64_encode(file_get_contents("my.torrent")));[/QUOTE]
?>

any suggestions?
thanks in advance
 
D

Diez B. Roggisch

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-[QUOTE]
cacheTorrent(base64_encode(file_get_contents("my.torrent")));[/QUOTE]
?>

any suggestions?[/QUOTE]

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top