I am interested in getting keep-alive connections working with suds
because it has large performance benefits for my application. I
noticed that there was some discussion in October about persistent
connections:
https://www.redhat.com/archives/fedora-suds-list/2009-October/msg00038.html
Rod -> you were going to follow up to the list about your results.
Have you had any luck till now in getting that working? If you did, is
it possible to share your solution?
Hi all,
It seems like a few people are interested in persistent connections...
below is how I got suds working with httplib2. I don't have a need for
cookies or proxies etc so the solution below is lacking them (if
anyone needs them take a look in suds/transport/http.py and the
httplib2 docs - it doesn't look like it would be too difficult to
add). Its also lacking any exception handling (although you'd probably
just catch them in your application). Reusing connections gives a nice
performance boost for my use-case. Anyway, thought I'd share it since
there seems to be some demand :-)
-Dave
#!/usr/bin/env python
from httplib2 import Http
from suds.transport import Transport
from suds.client import Client
class Httplib2Response:
pass
class Httplib2Transport(Transport):
def __init__(self, **kwargs):
Transport.__init__(self)
self.http = Http()
def send(self, request):
url = request.url
message = request.message
headers = request.headers
response = Httplib2Response()
response.headers, response.message = self.http.request(url,
"PUT", body=message, headers=headers)
return response
wsdl = "file:///yourWsdl.wsdl"
http = Httplib2Transport()
client = Client(wsdl, transport=http)
...