xsdata.formats.dataclass.client module

class xsdata.formats.dataclass.client.Config(style, location, transport, soap_action, input, output)[source]

Bases: object

Service configuration class.

Parameters
  • style (str) – binding style

  • location (str) – service endpoint url

  • transport (str) – transport namespace

  • soap_action (str) – soap action

  • input (Type) – input object type

  • output (Type) – output object type

style: str
location: str
transport: str
soap_action: str
input: Type
output: Type
classmethod from_service(obj, **kwargs)[source]

Instantiate from a generated service class.

Parameters
  • obj (Any) –

  • kwargs (Any) –

Return type

Config

class xsdata.formats.dataclass.client.TransportTypes[source]

Bases: object

SOAP = 'http://schemas.xmlsoap.org/soap/http'
class xsdata.formats.dataclass.client.Client(config, transport=<factory>, parser=<factory>, serializer=<factory>)[source]

Bases: object

Parameters
  • config (Config) – service configuration

  • transport (Transport) – transport instance to handle requests

  • parser (XmlParser) – xml parser instance to handle xml response parsing

  • serializer (XmlSerializer) – xml serializer instance to handle xml response parsing

config: xsdata.formats.dataclass.client.Config
transport: xsdata.formats.dataclass.transports.Transport
parser: xsdata.formats.dataclass.parsers.xml.XmlParser
serializer: xsdata.formats.dataclass.serializers.xml.XmlSerializer
dict_converter: xsdata.formats.dataclass.parsers.json.DictConverter
classmethod from_service(obj, **kwargs)[source]

Instantiate client from a service definition.

Parameters
Return type

Client

send(obj, headers=None)[source]

Send a request and parse the response according to the service configuration.

The input object can be a dictionary, or the input type instance directly

>>> params = {"body": {"add": {"int_a": 3, "int_b": 4}}}
>>> res = client.send(params)

Is equivalent with:

>>> req = CalculatorSoapAddInput(
>>> body=CalculatorSoapAddInput.Body(add=Add(3, 4)))
>>> res = client.send(req)
Parameters
  • obj (Any) – a params dictionary or the input type instance

  • headers (Optional[Dict]) – a dictionary of any additional headers.

Return type

Any

prepare_headers(headers)[source]

Prepare request headers according to the service configuration.

Don’t mutate input headers dictionary.

Raises

ClientValueError – If the service transport type is unsupported.

Parameters

headers (Dict) –

Return type

Dict

prepare_payload(obj)[source]

Prepare and serialize payload to be sent.

Raises

ClientValueError – If the config input type doesn’t match the given input.

Parameters

obj (Any) –

Return type

Any