Skip to content

utils

Supporting utilities for working with XML & SOAP

generate_xml_array

generate_xml_array(values: List[Any]) -> xsd.ComplexType

Generates a SOAP Array from a list of values.

Parameters:

Name Type Description Default
values List[Any]

a list of values to be converted to an XML SOAP Encoded Array.

required

Returns:

Type Description
xsd.ComplexType

xsd.ComplexType: zeep XML ComplexType representing an XML SOAP Encoded Array.

xmlmap_to_model

xmlmap_to_model(
    xmlmap: etree.Element,
    model_type: Type[T],
    *,
    strict: bool = True
) -> T

Converts XML ns2:Map to a model of type model_type.

Parameters:

Name Type Description Default
xmlmap etree.Element

xml subtree (ns2:Map) representing a model

required
model_type Type[T]

model type to map data into

required
strict bool

fail if the returned data doesn't match the model. Defaults to True.

True

Raises:

Type Description
ValueError

if strict is True and the returned data doesn't match the model.

ValueError

if the model_type is not an attrs-based model.

Returns:

Name Type Description
T T

generated model instance