![]() |
Table of Contents
SudsInstallationThe Suds module can be installed by:
SOAP Message TraceIt is useful when debugging a client to be able to see the actual SOAP messages exchanged. Suds provides a loggng option which can be used to enable output of these messages: import logging # Send log messages to console logging.basicConfig(level=logging.INFO) # Set Suds logging level to debug, outputs the SOAP messages. logging.getLogger('suds.client').setLevel(logging.DEBUG) ProxiesIn some environments it is necessary to configure a proxy before a client can connect to external services. To use a HTTP proxy with Suds: proxyOpts = {'http': 'proxy.example.com:8080'} client.set_options(proxy=proxyOpts)
To support the use of the # Configure HTTP proxy from OS environment (e.g. http_proxy="http://proxy.example.com:8080") import os proxyOpts = dict() if os.environ.has_key('http_proxy'): proxyOpts['http'] = os.environ['http_proxy'].replace('http://', '') elif os.environ.has_key('HTTP_PROXY'): proxyOpts['http'] = os.environ['HTTP_PROXY'].replace('http://', '') if 'http' in proxyOpts: client.set_options(proxy=proxyOpts) User-Agent
HTTP clients usually provide information about what they are, this allows services to handle specific clients differently if necessary, and gives service providers information about how their services are being used. By default Suds does not set the HTTP User-Agent header (see RFC2616 section 14.43), instead using the default setting from urllib2 # Modify the user-agent to add a more specific prefix (see RFC2616 section 14.43) import platform import suds import urllib2 # User-agent string to use: # Example-Client/1.0 suds/0.3.9 (Python 2.5.2; Linux) Python-urllib/2.5 userAgent = 'Example-Client/1.0 suds/%s (Python %s; %s) Python-urllib/%s' % ( suds.__version__, platform.python_version(), platform.system(), urllib2.__version__ ) # Set HTTP headers httpHeaders = {'User-agent': userAgent} dbfetchSrv.set_options(headers=httpHeaders) Note: while the HTTP specification does not define a limit on the size of HTTP headers, web server implementations often do limit the maximum size of an HTTP header to 8KB or 16KB. If the server limit for an HTTP header is exceeded a “400 Bad Request” will be returned by the server. Sample ClientsMost SOAP Web Services at EMBL-EBI have sample clients which provide command-line access to the service and example code. For Python some of the clients are based on SUDS. Document/literal SOAP
![]() |