Persistent connections - anyone else interested / suggest howto / working on it?
by Rod Montgomery
Currently (i.e. r580 / 0.3.7 release candidate) Suds uses urllib2, which uses urllib, both from the standard Python library.
For Python 2.5.2, urllib2 adds a "Connection: close" header, with the following comment:
# We want to make an HTTP/1.1 request, but the addinfourl
# class isn't prepared to deal with a persistent connection.
# It will try to read all remaining data from the socket,
# which will block while the server waits for the next request.
# So make sure the connection gets closed after the (only)
# request.
(lines 1069-1074 of /usr/lib/python2.5/urllib2.py).
I'm interested in making Suds able to use persistent connections.
Twisted (twistedmatrix.com) seems to have an elaborate HTTP/1.1 Client module in development, that threatens to support
persistent connections, but I have been unable to figure out how stable it is, and I don't understand how hard it would be to
make Suds able to use it.
http://twistedmatrix.com/trac/wiki/TwistedWebClient
http://twistedmatrix.com/trac/ticket/3420
which leads to
http://twistedmatrix.com/trac/ticket/886
Another possibility is httplib2:
http://pypi.python.org/pypi/httplib2/python3-0.5.0
Neither project seems to have much recent development-mailing-list activity, though neither seems completely dead either.
The Right Thing To Do would be to make Suds' use of any external HTTP package optional, rather than mandatory, to avoid
putting Suds at the mercy of the stability of that external package.
Anyone else interested in having persistent connections in Suds?
Anyone else have other suggestions for how to go about getting them?
Anyone else actually working on this? (I don't see any open Suds-Trac tickets for it.)
Thanks!
13 years, 11 months
Clone "needs" messages
by Daniel Rodriguez
Hi,
I checked in the source code of 0.3.7 and in the subversion trunk and both
lack the "cloning" of the "messages" attribute. Trying to usethe "cloned"
object fails because it has no "messages".
Opening a ticket was my preferred way but it seems that the Fedora Account
System is not working properly, so there it goes
Original Code at the end of the Client.clone function
clone.sd = self.sd
return clone
New Code
clone.sd = self.sd
clone.messages = dict(tx=None, rx=None)
return clone
With that small modification, clone is (so far in my small attempts) working
for me.
Best regards
Daniel
13 years, 11 months
Cache behavior
by Matt C
I know that there's some work planned on the cache implementation but
I wanted to get this behavior out for the benefit of any tickets that
may open (by the way I'm happy to open one on this but I'm not sure I
know how).
I frequently run into this when instantiating a client (even with
cache = None in the constructor): SAXParseException: <unknown>:10:2:
mismatched tag, which indicates the cache issue that has come up
before on the list.
But, if I run the same command from the same interactive session, I
create my client object without any issues. In other words, if I run
c = Client(url, cache = None, doctor = doctor) and I get my mismatched
tag error, I simply run this command again for the second time and
I've got a working client.
I've not had a chance to look at the caching code yet so I don't have
any input to share beyond this. If I get the chance to poke at this a
bit more I'll update here.
-Matt
13 years, 11 months
Problems using the attached WSDL's
by Nick Wiesmueller
Hi,
I'm trying to use the attached WSDL's and I'm having some difficulties. I've
got this working in C# .NET but I think I don't understand how suds works.
I can create my client
>>> from suds import *
>>> from suds.client import Client
>>> client = Client("http://10.1.10.11:81/flex/rpc/zephyrrpcservice?wsdl")
My client looks like this.
>>> print client
Suds ( https://fedorahosted.org/suds/ ) version: 0.3.7 GA build:
R580-20091016
Service ( zephyrrpcservice ) tns="http://impl.rpc.thed.com/"
Prefixes (1)
ns0 = "http://rpc.thed.com/"
Ports (1):
(ZephyrRPCServicesImplPort)
Methods (1):
updateTestStatus(ns0:remoteTestResult testResult, )
Types (4):
ns0:exception
ns0:remoteTestResult
ns0:updateTestStatus
ns0:updateTestStatusResponse
With other WSDL's I was just able to access the methods at this point like
this
>>>client.someMethod()
This doesn't work with the attached WSDL's.
It looks like
client.service.updateTestStatus(remoteTestResult testResult)
might work (I could be totally wrong), but I don't know how to properly
create a remoteTestResult object.
Thanks for your help,
Nick Wiesmueller
QA Analyst
Singlewire Software
PO Box 46218
Madison, WI 53744-6218
Phone Direct - 608.298.1625
www.singlewire.com
13 years, 11 months
How to force NULL, xsi:nil, gsoap?
by Elyrwen Dynesh
Hello,
I ve just started using suds for accessing a webservice written with gsoap.
I have a problem with passing NULL arguments. When I call a remote method
which has a pointer argument and I dont not want to specify this argument,
suds nevertheless includes this argument in SOAP message with an empty
contents, like this:
<filter xsi:type="ns0:ReportFilter"/>
On the other hand, gsoap recognizes this as a non-empty argument and by no
means filter == NULL
Generally, gsoap treats an argument as NULL only if:
<filter xsi:nil="1">
or <filter ...> is not present in a SOAP message at all.
My question is how to force suds to send <filter xsi:nil="1"> or not at all
while using methods with pointers?
I use the following method calls:
client.service.someMethod(filter = None)
client.service.someMethod()
The method declaration in C++ is:
void someMethod(someType* filter = NULL) {
if (filter == NULL) {
//filter is never NULL
}
}
I've already checked, that when sending the same message suds generates
while calling client.service.someMethod(), but with
<filter xsi:type="ns0:ReportFilter"/> cut out, everything works fine and
filter == NULL
Anyone has a clue?
13 years, 11 months
TransportError needs a docstring, maybe a change in behavior
by Rod Montgomery
In file transport/__init__.py maybe change the class def to this?
class TransportError(Exception):
def __init__(self, reason, httpcode, fp=None):
"""
A transport exception
@param reason: Human-readable text message
@type reason: str
@param httpcode: 3-decimal-digit HTTP status code (RFC 2616)
@type httpcode: str
@param fp: either a file-like object, containing (?what?), or None
@type fp: stream
"""
Exception.__init__(self, reason)
self.httpcode = httpcode
self.fp = fp
I have not yet figured out exactly *what* is in the fp element, when it is not None. Anybody know offhand?
The Python Library Reference, section 2.3, says Exception is derived from BaseException and that raising BaseException
with a single argument -- as here -- makes that argument available both as the str() and unicode() values of the exception
and as the message attribute of the exception. "All arguments are also stored in args as a tuple, but it will eventually be
deprecated and thus its use is discouraged."
In Suds as it now stands, the only places that raise TransportError are in the open and send methods of the
HttpTransport class, in file transport/http.py. Both cases are in except u2.HTTPError clauses, where u2 is bound to
urllib2 from the stdlib:
For open:
except u2.HTTPError, e:
raise TransportError(str(e), e.code, e.fp)
For send:
except u2.HTTPError, e:
if e.code in (202,204):
result = None
else:
raise TransportError(e.msg, e.code, e.fp)
Why does open use str(e) where send uses e.msg ?
From the source code for HTTPError, it looks to me like e.msg and str(e) differ, in a way that would make it harder than
necessary to write a single handler for both versions of the exception. Am I missing something? Is there a good reason for
the difference?
I was tempted to open a ticket for this, but (a) the proposed changes seemed too trivial and (b) I thought I'd have a better
chance of getting my questions answered if I posted to the List instead.
I'm digging deeper into exactly how HTTPError works in urllib2 so I'll be able to make TransportError work as uniformly
as possible across the Suds-provided Transport and alternatives based on httplib2 and urllib3.
It might help my understanding, if I could look at a few cases that actually use TransportError non-trivially. Anyone have
any to share?
13 years, 11 months
HTTPS Client Authentication: Where do I get the key?
by Jacob Fenwick
Hello all,
I'm new to suds. I've managed to get the public.py example working, which is
great.
However, I'd like to get suds working over HTTPS.
My issue partially lies with my minimal understanding of exactly how
trusting X.509 certificates work. I know that in Java I can take a .cer
certificate issued by an authority, add it to my keystore, and then I'm able
to connect over HTTPS to make a SOAP call.
In David Norton's post at
http://www.threepillarsoftware.com/soap_client_auth on how to use HTTPS with
suds, you need a certificate, but you also need a key. I'm not quite sure
what this key is. Is this the public key of the endpoint I'm trying to
connect to? It surely can't be their private key. Or is this meant to be my
public key? Or my private key?
If this is the public key from the endpoint, then is there a way to generate
this key from the .cer file? Or if this is the public or private key of the
client, then is there a way to generate the user's public or private key?
On a related newbie SSL question, does each individual computer have its own
unique public/private key used for all SOAP endpoints? Or does a user
generate a new public/private key combination each time they want to talk to
a different SOAP endpoint (or any SSL endpoint for that matter)?
I've also tried reading the httplib documentation at
http://docs.python.org/library/httplib.html and I still haven't figured
this out.
Also, I'm curious if Michal Kochel's patch will be added to the system
https://fedorahosted.org/suds/ticket/227 . I've also tried this patch but
I've run into the same issues.
If anyone can shed some light on this problem I would be greatly
appreciative.
Thanks,
Jacob
13 years, 11 months
0.3.7 ServiceDefinition changes
by Matt C
In 0.3.6 I was able to peek at the (very useful!) attributes inside of
my client object, in particular c.sd.params, where I could iterate
over them and fetch each param.name attribute. It appears this has
changed in 0.3.7.
I've not had a chance to look into the code for 0.3.7 yet, but was
wondering if anyone knew of a way for me to quickly recreate the
c.sd.params list that I was able to see in 0.3.6?
Thanks in advance,
-Matt
13 years, 11 months
Stale suds cache causing wsdl parser errors
by Drew Bryant
Hello,
The protein data bank webservice that I commonly use updated their
wsdl recently, and when attempting to construct a
suds.client.Client(url) object for the service I was continually
getting the following error:
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (129, 0))
followed by a large traceback that ultimately failed in the
xml.sax.expatreader module as shown below:
SAXParseException:
/var/folders/aS/aScvrYapHoCwNJHk1sw9LE+++TI/-Tmp-/suds/suds-649682136.http:10:2:
mismatched tag
I was getting a similar error with several other web services that had
recently modified their wsdls so I removed all of the files in the
suds tmp folder:
/var/folders/aS/aScvrYapHoCwNJHk1sw9LE+++TI/-Tmp-/suds
(this is the path selected by suds on my mac running OS X 10.5.8)
After removing these tmp files, everything worked fine and I was able
to construct the suds.client.Client instances without issues.
This is the version of suds that I'm using (via macports):
====================================
py25-suds @0.3.6 (python, devel, net)
Description: Suds is a lightweight SOAP python client for
consuming Web Services.
Homepage: https://fedorahosted.org/suds/
Build Dependencies: py25-setuptools
Library Dependencies: python25
Platforms: darwin
License: unknown
Maintainers: mmoll(a)macports.org, openmaintainer(a)macports.org
====================================
one of the SOAP services I was accessing:
http://www.rcsb.org/pdb/services/pdbws?wsdl
Basically, I resolved my problem already, but I was wondering why suds
was using stale information in its tmp directory instead of building
the Clients from scratch. Is this an error with suds not removing
stale cache files? I can easily clear this directory every time I
want to construct a new Client to guarantee that I won't run into this
issue again, but is this a good idea?
Thanks,
Drew
13 years, 11 months