client
xsdata.formats.dataclass.client
Config
dataclass
Service configuration class.
Attributes:
Name | Type | Description |
---|---|---|
style | str | The binding style |
location | str | The service endpoint url |
transport | str | The transport namespace |
soap_action | str | The soap action |
input | type | The input class |
output | type | The output class |
Source code in xsdata/formats/dataclass/client.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
|
from_service(obj, **kwargs)
classmethod
Instantiate from a generated service class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj | Any | The service class | required |
**kwargs | Any | Override the service class properties style: The binding style location: The service endpoint url transport: The transport namespace soap_action: The soap action input: The input class output: The output class | {} |
Returns:
Type | Description |
---|---|
Config | A new config instance. |
Source code in xsdata/formats/dataclass/client.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
|
TransportTypes
Transport types.
Source code in xsdata/formats/dataclass/client.py
57 58 59 60 |
|
Client
A wsdl client.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config | Config | The service config instance | required |
transport | Optional[Transport] | The transport instance | None |
parser | Optional[XmlParser] | The xml parser instance | None |
serializer | Optional[XmlSerializer] | The xml serializer instance | None |
Source code in xsdata/formats/dataclass/client.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
|
__init__(config, transport=None, parser=None, serializer=None)
Initialize the client.
Source code in xsdata/formats/dataclass/client.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
|
from_service(obj, **kwargs)
classmethod
Instantiate client from a service class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj | type | The service class | required |
**kwargs | Any | Override the service class properties style: The binding style location: The service endpoint url transport: The transport namespace soap_action: The soap action input: The input class output: The output class | {} |
Returns:
Type | Description |
---|---|
Client | A new client instance. |
Source code in xsdata/formats/dataclass/client.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
|
send(obj, headers=None)
Build and send a request for the input object.
params = {"body": {"add": {"int_a": 3, "int_b": 4}}}
res = client.send(params)
req = CalculatorSoapAddInput(
body=CalculatorSoapAddInput.Body(add=Add(3, 4)))
res = client.send(req)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj | Any | The request model instance or a pure dictionary | required |
headers | Optional[dict] | Additional headers to pass to the transport | None |
Returns:
Type | Description |
---|---|
Any | The response model instance. |
Source code in xsdata/formats/dataclass/client.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
|
prepare_headers(headers)
Prepare the request headers.
It merges the custom user headers with the necessary headers to accommodate the service class configuration.
Raises:
Type | Description |
---|---|
ClientValueError | If the service transport type is not supported. |
Source code in xsdata/formats/dataclass/client.py
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
|
prepare_payload(obj)
Prepare and serialize the payload to be sent.
If the obj is a pure dictionary, it will be converted first to a request model instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj | Any | The request model instance or a pure dictionary | required |
Returns:
Type | Description |
---|---|
Union[str, bytes] | The serialized request body content as string or bytes. |
Raises:
Type | Description |
---|---|
ClientValueError | If the config input type doesn't match the given object. |
Source code in xsdata/formats/dataclass/client.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
|