-1

I 'm using Suds for RPC calls over SOAP, and the client refuses to cache between calls (resulting in waiting 30+ seconds waiting for the client to initialise). Can anyone see what needs to be done in addition to the below in order for caching to be enabled?

client = Client(WSDL_URL)
cache = client.options.cache
cache.setduration(days=10)
cache.setlocation(SUDS_CACHE_LOCATION)
dusan
  • 9,104
  • 3
  • 35
  • 55
Trent
  • 2,328
  • 3
  • 33
  • 51
  • WSDL file is 22KB (suds also goes to download all of the referenced schema which increases the load time) – Trent Jul 31 '12 at 12:41
  • If you save the WSDL to a local file and load it from Suds, does that improve the loading time? – dusan Jul 31 '12 at 13:36
  • Nope, still the same. Saved into the suds location by going to 'save as' and saving with the same filename. Not sure if there's any other info that suds requires when it's looking for cache hits? – Trent Aug 01 '12 at 10:54
  • Can you show us the WSDL URL or file? – dusan Aug 01 '12 at 14:33
  • Sure thing - the WSDL is at https://training-api.temando.com/schema/2009_06/server.wsdl – Trent Aug 02 '12 at 13:51
  • The first time I did `from suds.client import Client; client = Client('https://training-api.temando.com/schema/2009_06/server.wsdl')` took 30+ seconds, the second time it was very fast. – dusan Aug 03 '12 at 13:19
  • was a file created in the path indicated in setlocation? – Trent Aug 03 '12 at 22:48
  • Could you post your code so I can compare to what I have? – Trent Aug 03 '12 at 23:08
  • Only this: `from suds.client import Client; client = Client('https://training-api.temando.com/schema/2009_06/server.wsdl')` – dusan Aug 05 '12 at 00:51
  • If you were doing this from a Windows machine, then you probably had the same problem I did. Here's the solution: http://stackoverflow.com/questions/6038226/suds-is-not-reusing-cached-wsdls-and-xsds-although-i-expect-it-to – Mike M. Lin Jun 08 '13 at 23:57

1 Answers1

0

This is probably a bug in the library itself. The cache file needs to be written in binary mode. That can be fixed in cache.py:

1) In FileCache.put(), change this line:

f = self.open(fn, 'w')

to

f = self.open(fn, 'wb')

2) In FileCache.getf(), change this line:

return self.open(fn)

to

return self.open(fn, 'rb')

For more details, see:

Suds is not reusing cached WSDLs and XSDs, although I expect it to

Community
  • 1
  • 1
Mike M. Lin
  • 9,992
  • 12
  • 53
  • 62