The elementsoap.ElementSOAP Module

This module provides helper classes for SOAP client implementations.

Module Contents

decode(element) [#]

(Experimental) Decoder for the standard SOAP encoding scheme. This function supports SOAP arrays, and maps custom types to Python dictionaries (using accessor names as keys, and decoded elements as values).

element
Element.
Returns:
A Python object structure.
Raises ValueError:
If a subelement has an unknown type.

decode_element(element) [#]

(Experimental) Element decoder for the standard SOAP encoding scheme. This function only decodes individual elements. Use decode to handle nested data structures.

element
Element.
Returns:
A Python object, or None if the element argument was None.
Raises ValueError:
If the element has an unknown type.

namespace_parse(source) [#]

Namespace-aware parser. This parser attaches a namespace attribute to all elements.

source
Source (a file-like object).
Returns:
A 2-tuple containing an annotated element tree, and a qname resolution helper. The helper takes an element and a QName, and returns an expanded URL/local part string.

namespace_qname(element, qname) [#]

Convert a QName string to an Element-style URL/local part string. Note that the parser converts element tags and attribute names during parsing; this method should only be used on attribute values and text sections.

element
An element created by the namespace_parse function.
qname
The QName string.
Returns:
The expanded URL/local part string.
Raises SyntaxError:
If the QName prefix is not defined for this element.

SoapElement(parent, name, type=None, text=None) ⇒ Element [#]

SOAP element factory. This creates a value element, and appends it to a parent element.

parent
The parent element (usually a SOAP request element another SOAP element).
name
Element name.
type
Element type. Use None for untyped objects, a string for types in the standard XML Schema namespace, or a QName.
text
Element value.
Returns:
A SOAP value element.

SoapFault(faultcode, faultstring, faultactor, detail) (class) [#]

SOAP fault exception.

faultcode
SOAP fault code.
faultstring
SOAP fault description.
faultactor
SOAP fault actor.
detail
SOAP detail structure (an Element structure).

For more information about this class, see The SoapFault Class.

SoapHeader() ⇒ Element [#]

SOAP header factory.

Returns:
A SOAP header element structure.

SoapRequest(request, encodingStyle=SOAP_ENCODING) ⇒ Element [#]

SOAP request factory.

request
SOAP request URL.
encodingStyle
SOAP encoding style. Defaults to SOAP encoding. To create a request without an encodingStyle attribute, pass in None.
Returns:
A SOAP request element structure.

SoapSecurity(parent) [#]

SOAP Security element factory.

parent
The parent element, usually a SoapHeader
Returns:
A SOAP Security element structure.

SoapService(url=None) (class) [#]

Base class for SOAP service proxies.

url
Optional service URL. If omitted, the URL defaults to the default URL for this service (as defined by the url class attribute).

For more information about this class, see The SoapService Class.

SoapUsernameToken(parent, user, pword, expires=180) [#]

SOAP UsernameToken element factory.

parent
The parent element, usually a Soap:Security header
user
username string
pword
password string
expires
expiration time in seconds realtive to now.
Returns:
A SOAP UsernameToken element structure.

The SoapFault Class

SoapFault(faultcode, faultstring, faultactor, detail) (class) [#]

SOAP fault exception.

faultcode
SOAP fault code.
faultstring
SOAP fault description.
faultactor
SOAP fault actor.
detail
SOAP detail structure (an Element structure).

detail [#]

SOAP fault detail. This is either None or an Element structure.

faultactor [#]

SOAP fault actor.

faultcode [#]

SOAP fault code.

faultstring [#]

SOAP fault description.

The SoapService Class

SoapService(url=None) (class) [#]

Base class for SOAP service proxies.

url
Optional service URL. If omitted, the URL defaults to the default URL for this service (as defined by the url class attribute).

call(action, request, header=None) ⇒ Element [#]

Calls a remote SOAP method.

action
The SOAP action string.
request
Request element.
Returns:
A response element structure. This is the contents of the SOAP Body element.
Raises SoapFault:
If the server returned a SOAP Fault.
Raises HTTPError:
If the server returned an HTTP error code other than 200 (OK) or 500 (SOAP error).