suds.bindings package

Submodules

suds.bindings.binding module

(WS) SOAP binding classes.

class suds.bindings.binding.Binding(wsdl)

Bases: object

The SOAP binding class used to process outgoing and incoming SOAP messages per the WSDL port binding.

Variables:
  • wsdl – The WSDL.
  • schema – The collective schema contained within the WSDL.
  • options – A dictionary options.
body(content)

Build the B{<Body/>} for a SOAP outbound message.

Parameters:content (Element) – The body content.
Returns:The SOAP body fragment.
Return type:Element
bodycontent(method, args, kwargs)

Get the content for the SOAP body node.

Parameters:
  • method (service.Method) – A service method.
  • args (list) – method parameter values.
  • kwargs (dict) – Named (keyword) args for the method invoked.
Returns:

The XML content for the <body/>.

Return type:

[Element,…]

bodypart_types(method, input=True)

Get a list of parameter definitions (pdefs) defined for the specified method.

An input pdef is a (name, xsd.sxbase.SchemaObject) tuple, while an output pdef is a xsd.sxbase.SchemaObject.

Parameters:
  • method (service.Method) – A service method.
  • input (boolean) – Defines input/output message.
Returns:

A list of parameter definitions

Return type:

[pdef,…]

envelope(header, body)

Build the B{<Envelope/>} for a SOAP outbound message.

Parameters:
  • header (Element) – The SOAP message B{header}.
  • body (Element) – The SOAP message B{body}.
Returns:

The SOAP envelope containing the body and header.

Return type:

Element

get_message(method, args, kwargs)

Get a SOAP message for the specified method, args and SOAP headers.

This is the entry point for creating an outbound SOAP message.

Parameters:
  • method (service.Method) – The method being invoked.
  • args (list) – A list of args for the method invoked.
  • kwargs (dict) – Named (keyword) args for the method invoked.
Returns:

The SOAP envelope.

Return type:

Document

get_reply(method, replyroot)

Process the reply for the specified method by unmarshalling it into into Python object(s).

Parameters:
  • method (str) – The name of the invoked method.
  • replyroot (Element) – The reply XML root node received after invoking the specified method.
Returns:

The unmarshalled reply. The returned value is an Object or a list depending on whether the service returns a single object or a collection.

Return type:

Object or list

header(content)

Build the B{<Body/>} for a SOAP outbound message.

Parameters:content (Element) – The header content.
Returns:The SOAP body fragment.
Return type:Element
headercontent(method)

Get the content for the SOAP Header node.

Parameters:method (service.Method) – A service method.
Returns:The XML content for the <body/>.
Return type:[Element,…]
headpart_types(method, input=True)

Get a list of header parameter definitions (pdefs) defined for the specified method.

An input pdef is a (name, xsd.sxbase.SchemaObject) tuple, while an output pdef is a xsd.sxbase.SchemaObject.

Parameters:
  • method (service.Method) – A service method.
  • input (boolean) – Defines input/output message.
Returns:

A list of parameter definitions

Return type:

[pdef,…]

marshaller()

Get the appropriate XML encoder.

Returns:An MxLiteral marshaller.
Return type:MxLiteral
mkheader(method, hdef, object)

Builds a soapheader for the specified method using the header definition (hdef) and the specified value (object).

Parameters:
  • method (str) – A method name.
  • hdef (tuple: (name, xsd.sxbase.SchemaObject)) – A header definition.
  • object (any) – The header value.
Returns:

The parameter fragment.

Return type:

Element

mkparam(method, pdef, object)

Builds a parameter for the specified method using the parameter definition (pdef) and the specified value (object).

Parameters:
  • method (str) – A method name.
  • pdef (tuple: (name, xsd.sxbase.SchemaObject)) – A parameter definition.
  • object (any) – The parameter value.
Returns:

The parameter fragment.

Return type:

Element

options()
param_defs(method)

Get parameter definitions.

Each pdef is a (name, xsd.sxbase.SchemaObject) tuple.

Parameters:method (service.Method) – A service method.
Returns:A collection of parameter definitions
Return type:[pdef,…]
replycomposite(rtypes, nodes)

Construct a composite reply.

Called for replies with multiple output nodes.

Parameters:
Returns:

The unmarshalled composite object.

Return type:

Object,…

replycontent(method, body)

Get the reply body content.

Parameters:
  • method (service.Method) – A service method.
  • body (Element) – The SOAP body.
Returns:

The body content.

Return type:

[Element,…]

replylist(rt, nodes)

Construct a list reply.

Called for replies with possible multiple occurrences.

Parameters:
Returns:

A list of unmarshalled objects.

Return type:

[Object,…]

returned_types(method)

Get the method return value type(s).

Parameters:method (service.Method) – A service method.
Returns:Method return value type.
Return type:[xsd.sxbase.SchemaObject,…]
schema()
unmarshaller()

Get the appropriate schema based XML decoder.

Returns:Typed unmarshaller.
Return type:UmxTyped
class suds.bindings.binding.PartElement(name, resolved)

Bases: suds.xsd.sxbasic.Element

Message part referencing an XSD type and thus acting like an XSD element.

Variables:resolved – The part type.
implany()

Set the type to <xsd:any/> when implicit.

An element has an implicit <xsd:any/> type when it has no body and no explicitly defined type.

Returns:self
Return type:Element
namespace(prefix=None)

Get this schema element’s target namespace.

In case of reference elements, the target namespace is defined by the referenced and not the referencing element node.

Parameters:prefix (str) – The default prefix.
Returns:The schema element’s target namespace
Return type:(prefix,``URI``)
optional()

Get whether this type is optional.

Returns:True if optional, else False.
Return type:boolean
resolve(nobuiltin=False)

Resolve the node’s type reference and return the referenced type node.

Returns self if the type is defined locally, e.g. as a <complexType> subnode. Otherwise returns the referenced external node.

Parameters:nobuiltin – Flag indicating whether resolving to XSD built-in types should not be allowed.
Returns:The resolved (true) type.
Return type:SchemaObject

suds.bindings.document module

Classes for the (WS) SOAP document/literal binding.

class suds.bindings.document.Document(wsdl)

Bases: suds.bindings.binding.Binding

The document/literal style. Literal is the only (@use) supported since document/encoded is pretty much dead.

Although the SOAP specification supports multiple documents within the SOAP <body/>, it is very uncommon. As such, suds library supports presenting an RPC view of service methods defined with only a single document parameter. To support the complete specification, service methods defined with multiple documents (multiple message parts), are still presented using a full document view.

More detailed description:

An interface is considered wrapped if:
  • There is exactly one message part in that interface.
  • The message part resolves to an element of a non-builtin type.

Otherwise it is considered bare.

Bare interface is interpreted directly as specified in the WSDL schema, with each message part represented by a single parameter in the suds library web service operation proxy interface (input or output).

Wrapped interface is interpreted without the external wrapping document structure, with each of its contained elements passed through suds library’s web service operation proxy interface (input or output) individually instead of as a single document object.

bodycontent(method, args, kwargs)

Get the content for the SOAP body node.

Parameters:
  • method (service.Method) – A service method.
  • args (list) – method parameter values.
  • kwargs (dict) – Named (keyword) args for the method invoked.
Returns:

The XML content for the <body/>.

Return type:

[Element,…]

document(wrapper)

Get the document root. For document/literal, this is the name of the wrapper element qualified by the schema’s target namespace.

Parameters:wrapper (xsd.sxbase.SchemaObject) – The method name.
Returns:A root element.
Return type:Element
mkparam(method, pdef, object)

Expand list parameters into individual parameters each with the type information. This is because in document arrays are simply multi-occurrence elements.

param_defs(method)

Get parameter definitions for document literal.

replycontent(method, body)

Get the reply body content.

Parameters:
  • method (service.Method) – A service method.
  • body (Element) – The SOAP body.
Returns:

The body content.

Return type:

[Element,…]

returned_types(method)

Get the method return value type(s).

Parameters:method (service.Method) – A service method.
Returns:Method return value type.
Return type:[xsd.sxbase.SchemaObject,…]

suds.bindings.multiref module

Provides classes for handling soap multirefs.

class suds.bindings.multiref.MultiRef

Resolves and replaces multirefs. :ivar nodes: A list of non-multiref nodes. :type nodes: list :ivar catalog: A dictionary of multiref nodes by id. :type catalog: dict

build_catalog(body)

Create the catalog of multiref nodes by id and the list of non-multiref nodes. :param body: A soap envelope body node. :type body: Element

process(body)

Process the specified soap envelope body and replace multiref node references with the contents of the referenced node. :param body: A soap envelope body node. :type body: Element :return: The processed body :rtype: Element

replace_references(node)

Replacing the multiref references with the contents of the referenced nodes and remove the href attribute. Warning: since the ref is not cloned, :param node: A node to update. :type node: Element

soaproot(node)

Get whether the specified node is a soap encoded root. This is determined by examining @soapenc:root=’1’. The node is considered to be a root when the attribute is not specified. :param node: A node to evaluate. :type node: Element :return: True if a soap encoded root. :rtype: bool

update(node)

Update the specified node by replacing the multiref references with the contents of the referenced nodes and remove the href attribute. :param node: A node to update. :type node: Element :return: The updated node :rtype: Element

suds.bindings.rpc module

Classes for the (WS) SOAP rpc/literal and rpc/encoded bindings.

class suds.bindings.rpc.Encoded(wsdl)

Bases: suds.bindings.rpc.RPC

RPC/Encoded (section 5) binding style.

marshaller()

Get the appropriate XML encoder.

Returns:An MxLiteral marshaller.
Return type:MxLiteral
unmarshaller()

Get the appropriate schema based XML decoder.

Returns:Typed unmarshaller.
Return type:UmxTyped
class suds.bindings.rpc.RPC(wsdl)

Bases: suds.bindings.binding.Binding

RPC/Literal binding style.

bodycontent(method, args, kwargs)

Get the content for the SOAP body node.

Parameters:
  • method (service.Method) – A service method.
  • args (list) – method parameter values.
  • kwargs (dict) – Named (keyword) args for the method invoked.
Returns:

The XML content for the <body/>.

Return type:

[Element,…]

envelope(header, body)

Build the B{<Envelope/>} for a SOAP outbound message.

Parameters:
  • header (Element) – The SOAP message B{header}.
  • body (Element) – The SOAP message B{body}.
Returns:

The SOAP envelope containing the body and header.

Return type:

Element

method(method)

Get the document root. For rpc/(literal|encoded), this is the name of the method qualified by the schema tns.

Parameters:method (service.Method) – A service method.
Returns:A root element.
Return type:Element
param_defs(method)

Get parameter definitions.

Each pdef is a (name, xsd.sxbase.SchemaObject) tuple.

Parameters:method (service.Method) – A service method.
Returns:A collection of parameter definitions
Return type:[pdef,…]
replycontent(method, body)

Get the reply body content.

Parameters:
  • method (service.Method) – A service method.
  • body (Element) – The SOAP body.
Returns:

The body content.

Return type:

[Element,…]

Module contents

Provides modules containing classes to support Web Services (SOAP) bindings.