suds package

Submodules

suds.argparser module

Suds web service operation invocation function argument parser.

See the parse_args() function description for more detailed information.

suds.argparser.parse_args(method_name, param_defs, args, kwargs, external_param_processor, extra_parameter_errors)

Parse arguments for suds web service operation invocation functions.

Suds prepares Python function objects for invoking web service operations. This function implements generic binding agnostic part of processing the arguments passed when calling those function objects.

Argument parsing rules:
  • Each input parameter element should be represented by single regular Python function argument.
  • At most one input parameter belonging to a single choice parameter structure may have its value specified as something other than None.
  • Positional arguments are mapped to choice group input parameters the same as is done for a simple all/sequence group - each in turn.

Expects to be passed the web service operation’s parameter definitions (parameter name, type & optional ancestry information) in order and, based on that, extracts the values for those parameter from the arguments provided in the web service operation invocation call.

Ancestry information describes parameters constructed based on suds library’s automatic input parameter structure unwrapping. It is expected to include the parameter’s XSD schema ‘ancestry’ context, i.e. a list of all the parent XSD schema tags containing the parameter’s <element> tag. Such ancestry context provides detailed information about how the parameter’s value is expected to be used, especially in relation to other input parameters, e.g. at most one parameter value may be specified for parameters directly belonging to the same choice input group.

Rules on acceptable ancestry items:
  • Ancestry item’s choice() method must return whether the item represents a <choice> XSD schema tag.
  • Passed ancestry items are used ‘by address’ internally and the same XSD schema tag is expected to be identified by the exact same ancestry item object during the whole argument processing.

During processing, each parameter’s definition and value, together with any additional pertinent information collected from the encountered parameter definition structure, is passed on to the provided external parameter processor function. There that information is expected to be used to construct the actual binding specific web service operation invocation request.

Raises a TypeError exception in case any argument related errors are detected. The exceptions raised have been constructed to make them as similar as possible to their respective exceptions raised during regular Python function argument checking.

Does not support multiple same-named input parameters.

suds.builder module

The builder module provides an wsdl/xsd defined types factory

class suds.builder.Builder(resolver)

Builder used to construct an object for types defined in the schema

add_attributes(data, type)

add required attributes

build(name)

build a an object for the specified typename as defined in the schema

ordering(type)

get the ordering

process(data, type, history)

process the specified type then process its children

skip_child(child, ancestry)

get whether or not to skip the specified child

suds.cache module

Basic caching classes.

class suds.cache.Cache

Bases: object

An object cache.

clear()

Clear all objects from the cache.

get(id)

Get an object from the cache by id.

Parameters:id (str) – The object id.
Returns:The object, else None.
Return type:any
purge(id)

Purge an object from the cache by id.

Parameters:id (str) – A object id.
put(id, object)

Put an object into the cache.

Parameters:
  • id (str) – The object id.
  • object (any) – The object to add.
class suds.cache.DocumentCache(location=None, **duration)

Bases: suds.cache.FileCache

XML document file cache.

fnsuffix()

Get the file name suffix.

Returns:The suffix.
Return type:str
get(id)

Get an object from the cache by id.

Parameters:id (str) – The object id.
Returns:The object, else None.
Return type:any
put(id, object)

Put an object into the cache.

Parameters:
  • id (str) – The object id.
  • object (any) – The object to add.
class suds.cache.FileCache(location=None, **duration)

Bases: suds.cache.Cache

A file-based URL cache.

Variables:
  • fnprefix – The file name prefix.
  • remove_default_location_on_exit – Whether to remove the default cache location on process exit (default=True).
  • duration – The duration after which cached entries expire (0=never).
  • location – The cached file folder.
clear()

Clear all objects from the cache.

fnprefix = 'suds'
fnsuffix()

Get the file name suffix.

Returns:The suffix.
Return type:str
get(id)

Get an object from the cache by id.

Parameters:id (str) – The object id.
Returns:The object, else None.
Return type:any
purge(id)

Purge an object from the cache by id.

Parameters:id (str) – A object id.
put(id, data)

Put an object into the cache.

Parameters:
  • id (str) – The object id.
  • object (any) – The object to add.
remove_default_location_on_exit = True
class suds.cache.NoCache

Bases: suds.cache.Cache

The pass-through object cache.

get(id)

Get an object from the cache by id.

Parameters:id (str) – The object id.
Returns:The object, else None.
Return type:any
put(id, object)

Put an object into the cache.

Parameters:
  • id (str) – The object id.
  • object (any) – The object to add.
class suds.cache.ObjectCache(location=None, **duration)

Bases: suds.cache.FileCache

Pickled object file cache.

Variables:protocol – The pickling protocol.
fnsuffix()

Get the file name suffix.

Returns:The suffix.
Return type:str
get(id)

Get an object from the cache by id.

Parameters:id (str) – The object id.
Returns:The object, else None.
Return type:any
protocol = 2
put(id, object)

Put an object into the cache.

Parameters:
  • id (str) – The object id.
  • object (any) – The object to add.

suds.client module

Service proxy implementation providing access to web services.

class suds.client.Client(url, **kwargs)

Bases: suds.UnicodeMixin

A lightweight web service client.

Variables:wsdl – The WSDL object.

:type wsdl:Definitions :ivar service: The service proxy used to invoke operations. :type service: Service :ivar factory: The factory used to create objects. :type factory: Factory :ivar sd: The service definition :type sd: ServiceDefinition

add_prefix(prefix, uri)

Add static mapping of an XML namespace prefix to a namespace.

Useful for cases when a WSDL and referenced XSD schemas make heavy use of namespaces and those namespaces are subject to change.

Parameters:
  • prefix (str) – An XML namespace prefix.
  • uri (str) – An XML namespace URI.

@raise Exception: prefix already mapped.

clone()

Get a shallow clone of this object.

The clone only shares the WSDL. All other attributes are unique to the cloned object including options.

Returns:A shallow clone.
Return type:Client
classmethod dict(sobject)

Convert a sudsobject into a dictionary.

Parameters:sobject (Object) – A suds object
Returns:A dictionary of items contained in sobject.
Return type:dict
classmethod items(sobject)

Extract items from a suds object.

Much like the items() method works on dict.

Parameters:sobject (Object) – A suds object
Returns:A list of items contained in sobject.
Return type:[(key, value),..]
classmethod metadata(sobject)

Extract the metadata from a suds object.

Parameters:sobject (Object) – A suds object
Returns:The object’s metadata
Return type:sudsobject.Metadata
set_options(**kwargs)

Set options.

Parameters:kwargs – keyword arguments.

@see: Options

class suds.client.Factory(wsdl)

A factory for instantiating types defined in the WSDL.

Variables:
  • resolver – A schema type resolver.
  • builder – A schema object builder.
create(name)

Create a WSDL type by name.

Parameters:name (str) – The name of a type defined in the WSDL.
Returns:The requested object.
Return type:Object
separator(ps)

Set the path separator.

Parameters:ps (char) – The new path separator.
class suds.client.Method(client, method)

The method (namespace) object.

Variables:

:type raw Method.

clientclass(kwargs)

Get SOAP client class.

faults()

Get faults option.

class suds.client.MethodSelector(client, methods, qn)

The B{method} selector is used to select a B{method} by name.

Variables:
  • __client – A suds client.
  • __methods – A dictionary of methods.
  • __qn – The qualified name of the method (used for logging).
class suds.client.PortSelector(client, ports, qn)

The B{port} selector is used to select a web service B{port}.

In cases where multiple ports have been defined and no default has been specified, the port is found by name (or index) and a MethodSelector for the port is returned. In all cases, attribute access is forwarded to the MethodSelector for either the first port or the default port (when specified).

Variables:
  • __client – A suds client.
  • __ports – A list of service ports.
  • __qn – The qualified name of the port (used for logging).
class suds.client.RequestContext(process_reply, envelope)

A request context.

Returned by a suds Client when invoking a web service operation with the nosend enabled. Allows the caller to take care of sending the request himself and return back the reply data for further processing.

Variables:envelope – The SOAP request envelope.
process_reply(reply, status=None, description=None)

Re-entry for processing a successful reply.

Depending on how the retxml option is set, may return the SOAP reply XML or process it and return the Python object representing the returned value.

Parameters:
  • reply (bytes) – The SOAP reply envelope.
  • status (int) – The HTTP status code.
  • description (bytes) – Additional status description.
Returns:

The invoked web service operation return value.

Return type:

builtin``|``subclass of Object`|``bytes``|``None`

class suds.client.ServiceSelector(client, services)

The B{service} selector is used to select a web service.

Most WSDLs only define a single service in which case access by subscript is passed through to a PortSelector. This is also the behavior when a default service has been specified. In cases where multiple services have been defined and no default has been specified, the service is found by name (or index) and a PortSelector for the service is returned. In all cases, attribute access is forwarded to the PortSelector for either the first service or the default service (when specified).

Variables:
  • __client – A suds client.
  • __services – A list of WSDL services.

suds.metrics module

The metrics module defines classes and other resources designed for collecting and reporting performance metrics.

class suds.metrics.Timer
duration()
start()
stop()

suds.options module

Suds basic options classes.

class suds.options.Options(**kwargs)

Bases: suds.properties.Skin

Options:
  • B{cache} - The XML document cache. May be set to None for no caching.
    • type: Cache
    • default: NoCache()
  • B{documentStore} - The XML document store used to access locally

    stored documents without having to download them from an external location. May be set to None for no internal suds library document store.

    • type: DocumentStore
    • default: defaultDocumentStore
  • B{extraArgumentErrors} - Raise exceptions when unknown message parts

    are detected when receiving a web service reply, compared to the operation’s WSDL schema definition.

    • type: bool
    • default: True
  • B{allowUnknownMessageParts} - Raise exceptions when extra arguments are

    detected when invoking a web service operation, compared to the operation’s WSDL schema definition.

    • type: bool
    • default: False
  • B{faults} - Raise faults raised by server, else return tuple from
    service method invocation as (httpcode, object).
    • type: bool
    • default: True
  • B{service} - The default service name.
    • type: str
    • default: None
  • B{port} - The default service port name, not tcp port.
    • type: str
    • default: None
  • B{location} - This overrides the service port address URL defined
    in the WSDL.
    • type: str
    • default: None
  • B{transport} - The message transport.
    • type: Transport
    • default: None
  • B{soapheaders} - The soap headers to be included in the soap message.
    • type: any
    • default: None
  • B{wsse} - The web services security provider object.
    • type: Security
    • default: None
  • B{doctor} - A schema doctor object.
    • type: Doctor
    • default: None
  • B{xstq} - The B{x}ml B{s}chema B{t}ype B{q}ualified flag indicates

    that the xsi:type attribute values should be qualified by namespace.

    • type: bool
    • default: True
  • B{prefixes} - Elements of the soap message should be qualified (when
    needed) using XML prefixes as opposed to xmlns=”” syntax.
    • type: bool
    • default: True
  • B{retxml} - Flag that causes the raw soap envelope to be returned
    instead of the python object graph.
    • type: bool
    • default: False
  • B{prettyxml} - Flag that causes pretty xml to be rendered when
    generating the outbound soap envelope.
    • type: bool
    • default: False
  • B{autoblend} - Flag that ensures that the schema(s) defined within
    the WSDL import each other.
    • type: bool
    • default: False
  • B{cachingpolicy} - The caching policy.
    • type: int - 0 = Cache XML documents. - 1 = Cache WSDL (pickled) object.
    • default: 0
  • B{plugins} - A plugin container.
    • type: list
    • default: list()
  • B{nosend} - Create the soap envelope but do not send.

    When specified, method invocation returns a RequestContext instead of sending it.

    • type: bool
    • default: False
  • B{unwrap} - Enable automatic parameter unwrapping when possible.

    Enabled by default. If disabled, no input or output parameters are ever automatically unwrapped.

    • type: bool
    • default: True
  • B{sortNamespaces} - Namespaces are sorted alphabetically. If disabled,

    namespaces are left in the order they are received from the source. Enabled by default for historical purposes.

    • type: bool
    • default: True
class suds.options.TpLinker

Bases: suds.properties.AutoLinker

Transport (auto) linker used to manage linkage between transport objects Properties and those Properties that contain them.

updated(properties, prev, next)

Notification that a values was updated and the linkage between the properties contained with prev need to be relinked to the Properties contained within the next value.

suds.plugin module

The plugin module provides suds plugin implementation classes.

class suds.plugin.Context

Bases: object

Plugin context.

class suds.plugin.DocumentContext

Bases: suds.plugin.Context

The XML document load context.

Variables:
  • url – The URL.
  • document – Either the XML text or the B{parsed} document root.
class suds.plugin.DocumentPlugin

Bases: suds.plugin.Plugin

Base class for suds document plugins.

loaded(context)

Suds has loaded a WSDL/XSD document.

Provides the plugin with an opportunity to inspect/modify the unparsed document. Called after each WSDL/XSD document is loaded.

Parameters:context (DocumentContext) – The document context.
parsed(context)

Suds has parsed a WSDL/XSD document.

Provides the plugin with an opportunity to inspect/modify the parsed document. Called after each WSDL/XSD document is parsed.

Parameters:context (DocumentContext) – The document context.
class suds.plugin.InitContext

Bases: suds.plugin.Context

Init Context.

Variables:wsdl – The WSDL.
class suds.plugin.InitPlugin

Bases: suds.plugin.Plugin

Base class for all suds init plugins.

initialized(context)

Suds client initialization.

Called after WSDL the has been loaded. Provides the plugin with the opportunity to inspect/modify the WSDL.

Parameters:context (InitContext) – The init context.
class suds.plugin.MessageContext

Bases: suds.plugin.Context

The context for sending the SOAP envelope.

Variables:
  • envelope – The SOAP envelope to be sent.
  • reply – The reply.
class suds.plugin.MessagePlugin

Bases: suds.plugin.Plugin

Base class for suds SOAP message plugins.

marshalled(context)

Suds is about to send the specified SOAP envelope.

Provides the plugin with the opportunity to inspect/modify the envelope Document before it is sent.

Parameters:context (MessageContext) – The send context. The envelope is the envelope document.
parsed(context)

Suds has SAX parsed the received reply.

Provides the plugin with the opportunity to inspect/modify the SAX parsed DOM tree for the reply before it is unmarshalled.

Parameters:context (MessageContext) – The reply context. The reply is DOM tree.
received(context)

Suds has received the specified reply.

Provides the plugin with the opportunity to inspect/modify the received XML text before it is SAX parsed.

Parameters:context (MessageContext) – The reply context. The reply is the raw text.
sending(context)

Suds is about to send the specified SOAP envelope.

Provides the plugin with the opportunity to inspect/modify the message text before it is sent.

Parameters:context (MessageContext) – The send context. The envelope is the envelope text.
unmarshalled(context)

Suds has unmarshalled the received reply.

Provides the plugin with the opportunity to inspect/modify the unmarshalled reply object before it is returned.

Parameters:context (MessageContext) – The reply context. The reply is unmarshalled suds object.
class suds.plugin.Method(name, domain)

Plugin method.

Variables:
  • name – The method name.
  • domain – The plugin domain.
class suds.plugin.Plugin

Plugin base.

class suds.plugin.PluginContainer(plugins)

Plugin container provides easy method invocation.

Variables:
  • plugins – A list of plugin objects.
  • ctxclass – A dict of plugin method / context classes.
domains = {'document': (<class 'suds.plugin.DocumentContext'>, <class suds.plugin.DocumentPlugin>), 'init': (<class 'suds.plugin.InitContext'>, <class suds.plugin.InitPlugin>), 'message': (<class 'suds.plugin.MessageContext'>, <class suds.plugin.MessagePlugin>)}
class suds.plugin.PluginDomain(ctx, plugins)

The plugin domain.

Variables:
  • ctx – A context.
  • plugins – A list of plugins (targets).

suds.properties module

Properties classes.

class suds.properties.AutoLinker

Bases: object

Base class, provides interface for automatic link management between a Properties object and the Properties contained within values.

updated(properties, prev, next)

Notification that a values was updated and the linkage between the properties contained with prev need to be relinked to the Properties contained within the next value.

class suds.properties.Definition(name, classes, default, linker=<suds.properties.AutoLinker object>)

Property definition. :ivar name: The property name. :type name: str :ivar classes: The (class) list of permitted values :type classes: tuple :ivar default: The default value. :ivar type: any

nvl(value=None)

Convert the value into the default when None. :param value: The proposed value. :type value: any :return: The default when value is None, else value. :rtype: any

validate(value)

Validate the value is of the correct class. :param value: The value to validate. :type value: any @raise AttributeError: When value is invalid.

class suds.properties.Endpoint(link, target)

Bases: object

Link endpoint (wrapper). :ivar link: The associated link. :type link: Link :ivar target: The properties object. :type target: Property

teardown()
class suds.properties.Inspector(options)

Wrapper inspector.

get(name, *df)

Get the value of a property by name. :param name: The property name. :type name: str :param df: An optional value to be returned when the value

is not set
Returns:The stored value, or df[0] if not set.
Return type:any

Link (associate) this object with an``other`` properties object to create a network of properties. Links are bidirectional. :param other: The object to link. :type other: Properties :return: self :rtype: Properties

Unlink (disassociate) the specified properties object. :param other: The object to unlink. :type other: Properties :return: self :rtype: Properties

update(**kwargs)

Update the property values as specified by keyword/value. :param kwargs: A list of property name/values to set. :type kwargs: dict :return: self :rtype: Properties

Bases: object

Property link object. :ivar endpoints: A tuple of the (2) endpoints of the link. :type endpoints: tuple(2)

teardown()

Teardown the link. Removes endpoints from properties links collection. :return: self :rtype: Link

validate(pA, pB)

Validate that the two properties may be linked. :param pA: Endpoint (A) to link. :type pA: Endpoint :param pB: Endpoint (B) to link. :type pB: Endpoint :return: self :rtype: Link

class suds.properties.Properties(domain, definitions, kwargs)

Represents basic application properties. Provides basic type validation, default values and link/synchronization behavior. :ivar domain: The domain name. :type domain: str :ivar definitions: A table of property definitions. :type definitions: {name: Definition} :ivar links: A list of linked property objects used to create

a network of properties.
Variables:defined – A dict of property values.
definition(name)

Get the definition for the property name. :param name: The property name to find the definition for. :type name: str :return: The property definition :rtype: Definition @raise AttributeError: On not found.

domains(history=None)

Get the set of all domain names. :param history: A history of nodes checked to prevent

circular hunting.
Returns:A set of domain names.
Return type:list
get(name, *df)

Get the value of a property by name. :param name: The property name. :type name: str :param df: An optional value to be returned when the value

is not set
Returns:The stored value, or df[0] if not set.
Return type:any
keys(history=None)

Get the set of all property names. :param history: A history of nodes checked to prevent

circular hunting.
Returns:A set of property names.
Return type:list

Link (associate) this object with an``other`` properties object to create a network of properties. Links are bidirectional. :param other: The object to link. :type other: Properties :return: self :rtype: Properties

notset(name)

Get whether a property has never been set by name. :param name: A property name. :type name: str :return: True if never been set. :rtype: bool

prime()

Prime the stored values based on default values found in property definitions. :return: self :rtype: Properties

provider(name, history=None)

Find the provider of the property by name. :param name: The property name. :type name: str :param history: A history of nodes checked to prevent

circular hunting.
Returns:The provider when found. Otherwise, None (when nested) and self when not nested.
Return type:Properties
set(name, value)

Set the value of a property by name. The value is validated against the definition and set to the default when value is None. :param name: The property name. :type name: str :param value: The new property value. :type value: any :return: self :rtype: Properties

str(history)

Unlink (disassociate) the specified properties object. :param others: The list object to unlink. Unspecified means unlink all. :type others: [Properties,..] :return: self :rtype: Properties

unset(name)

Unset a property by name. :param name: A property name. :type name: str :return: self :rtype: Properties

update(other)

Update the property values as specified by keyword/value. :param other: An object to update from. :type other: (dict|:class:Properties) :return: self :rtype: Properties

class suds.properties.Skin(domain, definitions, kwargs)

Bases: object

The meta-programming skin around the Properties object. :ivar __pts__: The wrapped object. :type __pts__: Properties.

class suds.properties.Unskin

Bases: object

suds.reader module

XML document reader classes providing integration with the suds library’s caching system.

class suds.reader.DefinitionsReader(options, fn)

Bases: suds.reader.Reader

Integrates between the WSDL Definitions object and the object cache.

Variables:fn – A factory function used to create objects not found in the cache.
open(url)

Open a WSDL schema at the specified URL.

First, the WSDL schema is looked up in the object cache. If not found, a new one constructed using the fn factory function and the result is cached for the next open().

Parameters:url (str.) – A WSDL URL.
Returns:The WSDL object.
Return type:Definitions
class suds.reader.DocumentReader(options)

Bases: suds.reader.Reader

Integrates between the SAX Parser and the document cache.

open(url)

Open an XML document at the specified URL.

First, a preparsed document is looked up in the object cache. If not found, its content is fetched from an external source and parsed using the SAX parser. The result is cached for the next open().

Parameters:url (str.) – A document URL.
Returns:The specified XML document.
Return type:Document
class suds.reader.Reader(options)

Bases: object

Provides integration with the cache.

Variables:options – An options object.
mangle(name, x)

Mangle the name by hashing the name and appending x.

Returns:The mangled name.
Return type:str

suds.resolver module

The resolver module provides a collection of classes that provide wsdl/xsd named type resolution.

class suds.resolver.Frame(type, resolved=None, ancestry=())
class Empty
class suds.resolver.GraphResolver(schema)

Bases: suds.resolver.TreeResolver

The graph resolver is a stateful Object graph resolver used to resolve each node in a tree. As such, it mirrors the tree structure to ensure that nodes are resolved in context.

find(name, object, resolved=False, push=True)
Parameters:
  • name (basestring) – The name of the object to be resolved.
  • object ((any|:class:Object)) – The name’s value.
  • resolved (boolean) – A flag indicating that the fully resolved type should be returned.
  • push (boolean) – Indicates that the resolved type should be pushed onto the stack.
Returns:

The found schema type

Return type:

xsd.sxbase.SchemaObject

known(object)

Get the type specified in the object’s metadata.

query(name)

Blindly query the schema by name.

wsdl()

Get the wsdl.

class suds.resolver.NodeResolver(schema)

Bases: suds.resolver.TreeResolver

The node resolver is a stateful XML document resolver used to resolve each node in a tree. As such, it mirrors the tree structure to ensure that nodes are resolved in context.

find(node, resolved=False, push=True)
Parameters:
  • node (sax.element.Element) – An xml node to be resolved.
  • resolved (boolean) – A flag indicating that the fully resolved type should be returned.
  • push (boolean) – Indicates that the resolved type should be pushed onto the stack.
Returns:

The found schema type

Return type:

xsd.sxbase.SchemaObject

findattr(name, resolved=True)

Find an attribute type definition. :param name: An attribute name. :type name: basestring :param resolved: A flag indicating that the fully resolved type should be

returned.
Returns:The found schema type
Return type:xsd.sxbase.SchemaObject
known(node)

Resolve type referenced by @xsi:type.

query(name, node)

Blindly query the schema by name.

class suds.resolver.PathResolver(wsdl, ps='.')

Bases: suds.resolver.Resolver

Resolves the definition object for the schema type located at a given path. The path may contain (.) dot notation to specify nested types. :ivar wsdl: A wsdl object. :type wsdl: wsdl.Definitions

exception BadPath

Bases: exceptions.Exception

branch(root, parts)

Traverse the path until a leaf is reached. :param parts: A list of path parts. :type parts: [str,..] :param root: The root. :type root: xsd.sxbase.SchemaObject :return: The end of the branch. :rtype: xsd.sxbase.SchemaObject

find(path, resolved=True)

Get the definition object for the schema type located at the specified path. The path may contain (.) dot notation to specify nested types. Actually, the path separator is usually a (.) but can be redefined during contruction. :param path: A (.) separated path to a schema type. :type path: basestring :param resolved: A flag indicating that the fully resolved type

should be returned.
Returns:The found schema type
Return type:xsd.sxbase.SchemaObject
leaf(parent, parts)

Find the leaf. :param parts: A list of path parts. :type parts: [str,..] :param parent: The leaf’s parent. :type parent: xsd.sxbase.SchemaObject :return: The leaf. :rtype: xsd.sxbase.SchemaObject

qualify(name)
Qualify the name as either:
  • plain name
  • ns prefixed name (eg: ns0:Person)
  • fully ns qualified name (eg: {http://myns-uri}Person)
Parameters:name (str) – The name of an object in the schema.
Returns:A qualified name.
Return type:qname
root(parts)

Find the path root. :param parts: A list of path parts. :type parts: [str,..] :return: The root. :rtype: xsd.sxbase.SchemaObject

split(s)

Split the string on (.) while preserving any (.) inside the ‘{}’ alternalte syntax for full ns qualification. :param s: A plain or qualified name. :type s: str :return: A list of the name’s parts. :rtype: [str,..]

class suds.resolver.Resolver(schema)

An abstract schema-type resolver. :ivar schema: A schema object. :type schema: xsd.schema.Schema

find(name, resolved=True)

Get the definition object for the schema object by name. :param name: The name of a schema object. :type name: basestring :param resolved: A flag indicating that the fully resolved type

should be returned.
Returns:The found schema type
Return type:xsd.sxbase.SchemaObject
class suds.resolver.Stack

Bases: list

class suds.resolver.TreeResolver(schema)

Bases: suds.resolver.Resolver

The tree resolver is a stateful tree resolver used to resolve each node in a tree. As such, it mirrors the tree structure to ensure that nodes are resolved in context. :ivar stack: The context stack. :type stack: list

depth()

Get the current stack depth. :return: The current stack depth. :rtype: int

getchild(name, parent)

Get a child by name.

pop()

Pop the frame at the top of the stack. :return: The popped frame, else None. :rtype: Frame

push(x)

Push an object onto the stack. :param x: An object to push. :type x: Frame :return: The pushed frame. :rtype: Frame

reset()

Reset the resolver’s state.

top()

Get the frame at the top of the stack. :return: The top frame, else None. :rtype: Frame

suds.servicedefinition module

The service definition provides a textual representation of a service.

class suds.servicedefinition.ServiceDefinition(wsdl, service)

Bases: suds.UnicodeMixin

A service definition provides an object used to generate a textual description of a service. :ivar wsdl: A wsdl. :type wsdl: wsdl.Definitions :ivar sort_namespaces: Whether to sort namespaces on storing them. :ivar service: The service object. :type service: suds.wsdl.Service :ivar ports: A list of port-tuple: (port, [(method-name, pdef)]) :type ports: [port-tuple,..] :ivar prefixes: A list of remapped prefixes. :type prefixes: [(prefix,uri),..] :ivar types: A list of type definitions :type types: [Type,..]

addports()

Look through the list of service ports and construct a list of tuples where each tuple is used to describe a port and its list of methods as: (port, [method]). Each method is a tuple: (name, [pdef,..]) where each pdef is a tuple: (param-name, type).

description()

Get a textual description of the service for which this object represents. :return: A textual description. :rtype: str

findport(port)

Find and return a port tuple for the specified port. Created and added when not found. :param port: A port. :type port: service.Port :return: A port tuple. :rtype: (port, [method])

getprefix(u)

Get the prefix for the specified namespace (URI) :param u: A namespace URI. :type u: str :return: The namspace. :rtype: (prefix, uri).

getprefixes()

Add prefixes for each namespace referenced by parameter types.

nextprefix()

Get the next available prefix. This means a prefix starting with ‘ns’ with a number appended as (ns0, ns1, ..) that is not already defined in the WSDL document.

paramtypes()

Get all parameter types.

publictypes()

Get all public types.

pushprefixes()

Add our prefixes to the WSDL so that when users invoke methods and reference the prefixes, they will resolve properly.

xlate(type)

Get a (namespace) translated qualified name for specified type. :param type: A schema type. :type type: suds.xsd.sxbasic.SchemaObject :return: A translated qualified name. :rtype: str

suds.serviceproxy module

The service proxy provides access to web services.

Replaced by: client.Client

class suds.serviceproxy.ServiceProxy(url, **kwargs)

Bases: suds.UnicodeMixin

A lightweight soap based web service proxy. :ivar __client__: A client.

Everything is delegated to the 2nd generation API.

@note: Deprecated, replaced by Client.

get_enum(name)

Get an instance of an enumeration defined in the WSDL by name. :param name: The name of a enumeration defined in the WSDL. :type name: str :return: An instance on success, else None :rtype: sudsobject.Object

get_instance(name)

Get an instance of a WSDL type by name :param name: The name of a type defined in the WSDL. :type name: str :return: An instance on success, else None :rtype: sudsobject.Object

suds.soaparray module

The soaparray module provides XSD extensions for handling soap (section 5) encoded arrays.

class suds.soaparray.Attribute(schema, root, aty)

Bases: suds.xsd.sxbasic.Attribute

Represents an XSD <attribute/> that handles special attributes that are extensions for WSDLs. :ivar aty: Array type information. :type aty: The value of wsdl:arrayType.

autoqualified()

The list of auto qualified attribute values.

Qualification means to convert values into qref.

Returns:A list of attribute names.
Return type:list
description()

Get the names used for repr() and str() description.

Returns:A dictionary of relevant attributes.
Return type:[str,..]

suds.store module

Support for holding XML document content that may then be accessed internally by suds without having to download them from an external source. Also contains XML document content to be distributed alongside the suds library.

class suds.store.DocumentStore(*args, **kwargs)

Bases: object

Local XML document content repository.

Each XML document is identified by its location, i.e. URL without any protocol identifier. Contained XML documents can be looked up using any URL referencing that same location.

open(url)

Open a document at the specified URL.

The document URL’s needs not contain a protocol identifier, and if it does, that protocol identifier is ignored when looking up the store content.

Missing documents referenced using the internal ‘suds’ protocol are reported by raising an exception. For other protocols, None is returned instead.

Parameters:url (str) – A document URL.
Returns:Document content or None if not found.
Return type:bytes

suds.sudsobject module

Provides a collection of suds objects primarily used for highly dynamic interactions with WSDL/XSD defined types.

class suds.sudsobject.Facade(name)

Bases: suds.sudsobject.Object

class suds.sudsobject.Factory
cache = {}
classmethod metadata()
classmethod object(classname=None, dict={})
classmethod property(name, value=None)
classmethod subclass(name, bases, dict={})
class suds.sudsobject.Iter(sobject)
next()
class suds.sudsobject.Metadata

Bases: suds.sudsobject.Object

class suds.sudsobject.Object

Bases: suds.UnicodeMixin

class suds.sudsobject.Printer

Pretty printing of a Object object.

exclude(d, item)

Check metadata for excluded items.

classmethod indent(n)
print_collection(c, h, n)

Print collection using the specified indent (n) and newline (nl).

print_dictionary(d, h, n, nl=False)

Print complex using the specified indent (n) and newline (nl).

print_object(d, h, n, nl=False)

Print complex using the specified indent (n) and newline (nl).

process(object, h, n=0, nl=False)

Print object using the specified indent (n) and newline (nl).

tostr(object, indent=-2)

Get s string representation of object.

unwrap(d, item)

Translate (unwrap) using an optional wrapper function.

class suds.sudsobject.Property(value)

Bases: suds.sudsobject.Object

get()
items()
set(value)
suds.sudsobject.asdict(sobject)

Convert a sudsobject into a dictionary.

Parameters:sobject (Object) – A suds object
Returns:A python dictionary containing the items contained in sobject.
Return type:dict
suds.sudsobject.footprint(sobject)

Get the virtual footprint of the object.

This is really a count of all the significant value attributes in the branch.

Parameters:sobject (Object) – A suds object.
Returns:The branch footprint.
Return type:int
suds.sudsobject.items(sobject)

Extract the items from a suds object.

Much like the items() method works on dict.

Parameters:sobject (Object) – A suds object
Returns:A list of items contained in sobject.
Return type:[(key, value),..]
suds.sudsobject.merge(a, b)

Merge all attributes and metadata from a to b.

Parameters:
  • a (Object) – A source object
  • b (Object) – A destination object

suds.version module

Module containing the library’s version information.

This version information has been extracted into a separate file so it can be

read from the setup.py script without having to import the suds package itself. See the setup.py script for more detailed information.

suds.wsdl module

The wsdl module provides an objectification of the WSDL.

The primary class is Definitions, representing the root element found in a WSDL schema document.

class suds.wsdl.Binding(root, definitions)

Bases: suds.wsdl.NamedObject

Represents <binding/>.

Variables:operations – A list of contained operations.
add_operations(root, definitions)

Add <operation/> children.

body(definitions, body, root)

Add the input/output body properties.

do_resolve(definitions)

Resolve named references to other WSDL objects. This includes cross-linking information (from) the portType (to) the SOAP protocol information on the binding for each operation.

Parameters:definitions (Definitions) – A definitions object.
header(definitions, parent, root)

Add the input/output header properties.

operation(name)

Shortcut used to get a contained operation by name.

Parameters:name (str) – An operation name.
Returns:The named operation.
Return type:Operation

@raise MethodNotFound: When not found.

soaproot()

Get the soap:binding.

class suds.wsdl.Definitions(url, options, imported_definitions=None)

Bases: suds.wsdl.WObject

Root container for all the WSDL objects defined by <wsdl:definitions/>.

Variables:
  • id – The object id.
  • options – An options dictionary.
  • url – The URL used to load the object.
  • tns – The target namespace for the WSDL.
  • schema – The collective WSDL schema object.
  • children – The raw list of child objects.
  • imports – The list of Import children.
  • messages – The dictionary of Message children keyed by qname.
  • port_types – The dictionary of PortType children keyed by qname.
  • bindings – The dictionary of Binding children keyed by qname.
  • service – The service object.
Tag = 'definitions'
add_children(root)

Add child objects using the factory.

add_methods(service)

Build method view for service.

build_schema()

Process Types objects and create the schema collection.

mktns(root)

Get/create the target namespace.

open_imports(imported_definitions)

Import the imported WSDLs.

resolve()

Tell all children to resolve themselves.

set_wrapped()

Set (wrapped|bare) flag on messages.

class suds.wsdl.Factory

Simple WSDL object factory.

Variables:tags – Dictionary of tag–>constructor mappings.
classmethod create(root, definitions)

Create an object based on the root tag name.

Parameters:
  • root (Element) – An XML root element.
  • definitions (Definitions) – A definitions object.
Returns:

The created object.

Return type:

WObject

tags = {'binding': <class 'suds.wsdl.Binding'>, 'import': <class 'suds.wsdl.Import'>, 'message': <class 'suds.wsdl.Message'>, 'portType': <class 'suds.wsdl.PortType'>, 'service': <class 'suds.wsdl.Service'>, 'types': <class 'suds.wsdl.Types'>}
class suds.wsdl.Import(root, definitions)

Bases: suds.wsdl.WObject

Represents the <wsdl:import/>.

Variables:
  • location – The value of the location attribute.
  • ns – The value of the namespace attribute.
  • imported – The imported object.
import_definitions(definitions, d)

Import/merge WSDL definitions.

import_schema(definitions, d)

Import schema as <types/> content.

load(definitions, imported_definitions)

Load the object by opening the URL.

class suds.wsdl.Message(root, definitions)

Bases: suds.wsdl.NamedObject

Represents <message/>.

Variables:parts – A list of message parts.
class suds.wsdl.NamedObject(root, definitions)

Bases: suds.wsdl.WObject

A B{named} WSDL object.

Variables:
  • name – The name of the object.
  • qname – The qualified name of the object.
class suds.wsdl.Part(root, definitions)

Bases: suds.wsdl.NamedObject

Represents <message><part/></message>.

Variables:
  • element – The value of the {element} attribute. Stored as a qref as converted by suds.xsd.qualify.
  • type – The value of the {type} attribute. Stored as a qref as converted by suds.xsd.qualify.
class suds.wsdl.Port(root, definitions, service)

Bases: suds.wsdl.NamedObject

Represents a service port.

Variables:
  • service – A service.
  • binding – A binding name.
  • location – The service location (URL).
method(name)

Get a method defined in this portType by name.

Parameters:name (str) – A method name.
Returns:The requested method object.
Return type:Method
class suds.wsdl.PortType(root, definitions)

Bases: suds.wsdl.NamedObject

Represents <portType/>.

Variables:operations – A list of contained operations.
do_resolve(definitions)

Resolve named references to other WSDL objects.

Parameters:definitions (Definitions) – A definitions object.
operation(name)

Shortcut used to get a contained operation by name.

Parameters:name (str) – An operation name.
Returns:The named operation.
Return type:Operation

@raise MethodNotFound: When not found.

class suds.wsdl.Service(root, definitions)

Bases: suds.wsdl.NamedObject

Represents <service/>.

Variables:
  • port – The contained ports.
  • methods – The contained methods for all ports.
do_resolve(definitions)

Resolve named references to other WSDL objects. Ports without SOAP bindings are discarded.

Parameters:definitions (Definitions) – A definitions object.
port(name)

Locate a port by name.

Parameters:name (str) – A port name.
Returns:The port object.
Return type:Port
setlocation(url, names=None)

Override the invocation location (URL) for service method.

Parameters:
  • url (A URL.) – A URL location.
  • names ([str,.]) – A list of method names. None=ALL
class suds.wsdl.Types(root, definitions)

Bases: suds.wsdl.WObject

Represents <types><schema/></types>.

contents()
imported()
local()
schema()
class suds.wsdl.WObject(root)

Bases: suds.sudsobject.Object

Base object for WSDL types.

Variables:root – The XML root element.
do_resolve(definitions)

Internal worker resolving named references to other WSDL objects.

May only be called once per instance.

Parameters:definitions (Definitions) – A definitions object.
resolve(definitions)

Resolve named references to other WSDL objects.

Can be safely called multiple times.

Parameters:definitions (Definitions) – A definitions object.

suds.wsse module

The wsse module provides WS-Security.

class suds.wsse.Security

Bases: suds.sudsobject.Object

WS-Security object. :ivar tokens: A list of security tokens :type tokens: [Token,…] :ivar signatures: A list of signatures. :type signatures: TBD :ivar references: A list of references. :type references: TBD :ivar keys: A list of encryption keys. :type keys: TBD

xml()

Get xml representation of the object. :return: The root node. :rtype: Element

class suds.wsse.Timestamp(validity=90)

Bases: suds.wsse.Token

Represents the Timestamp WS-Secuirty token. :ivar created: The token created. :type created: datetime :ivar expires: The token expires. :type expires: datetime

xml()
class suds.wsse.Token

Bases: suds.sudsobject.Object

Abstract security token.

classmethod now()
classmethod sysdate()
classmethod utc()
class suds.wsse.UsernameToken(username=None, password=None)

Bases: suds.wsse.Token

Represents a basic UsernameToken WS-Secuirty token. :ivar username: A username. :type username: str :ivar password: A password. :type password: str :type password_digest: A password digest :ivar nonce: A set of bytes to prevent replay attacks. :type nonce: str :ivar created: The token created. :type created: datetime

setcreated(dt=None)

Set created. :param dt: The created date & time.

Set as datetime.utc() when None.
setnonce(text=None)

Set nonce which is an arbitrary set of bytes to prevent replay attacks. :param text: The nonce text value.

Generated when None.
setnonceencoding(value=False)
setpassworddigest(passwd_digest)

Set password digest which is a text returned by auth WS.

xml()

Get xml representation of the object. :return: The root node. :rtype: Element

Module contents

Lightweight SOAP Python client providing a Web Service proxy.

exception suds.BuildError(name, exception)

Bases: exceptions.Exception

exception suds.MethodNotFound(name)

Bases: exceptions.Exception

exception suds.PortNotFound(name)

Bases: exceptions.Exception

class suds.Repr(x)
exception suds.ServiceNotFound(name)

Bases: exceptions.Exception

exception suds.TypeNotFound(name)

Bases: exceptions.Exception

class suds.UnicodeMixin

Bases: object

exception suds.WebFault(fault, document)

Bases: exceptions.Exception

suds.byte_str(s='', encoding='utf-8', input_encoding='utf-8', errors='strict')

Returns a byte string version of ‘s’, encoded as specified in ‘encoding’.

Accepts str & unicode objects, interpreting non-unicode strings as byte strings encoded using the given input encoding.

class suds.null

I{null} object used to pass NULL for optional XML nodes.

suds.objid(obj)
suds.tostr(object, encoding=None)

Get a unicode safe string representation of an object.