У меня есть SOAP служба, которая звонит так:
import zeep
import random
import string
from lxml import etree as ET
class Hostopia_SOAP():
def __init__(self, user, password, wsdl):
self.wsdl = wsdl
self.cred = self.set_cred(user, password)
self.sc = zeep.Client(self.wsdl)
def set_cred(self, user, password):
return {'username' : user, 'password' : password}
def get_all_domains(self, start=0, package=None, status=None, externalid=None, rserverid=None,
accountid=None, customernumber=None):
return self.sc.service.getAllDomains(self.cred,str(start),[ ])
Результат xml выглядит следующим образом:
<?xml version='1.0' encoding='utf-8'?>
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
<soap-env:Body>
<ns0:getAllDomains xmlns:ns0="urn:RRAD">
<primary>
<username>user</username>
<password>password</password>
</primary>
<startNumber>0</startNumber>
<conditions/>
</ns0:getAllDomains>
</soap-env:Body>
</soap-env:Envelope>
и все идет отлично!
Но, однако, я пытаюсь поставить некоторые условия, такие как:
self.sc.service.getAllDomains(self.cred,str(start),[ 'key1=value' ])
, в моем запросе я получаю эту ошибку:
Traceback (most recent call last):
File "z:/No-git/Scripts/HostoSOAP.py", line 286, in <module>
print(client.debug('getAllDomains', '0', ['status=OK']))
File "z:/No-git/Scripts/HostoSOAP.py", line 243, in debug
node = self.sc.create_message(self.sc.service, service, self.cred, *args)
File "F:\dev-tools-plugin\Anaconda3\lib\site-packages\zeep\client.py", line 139, in create_message
operation_name, args, kwargs, client=self
File "F:\dev-tools-plugin\Anaconda3\lib\site-packages\zeep\wsdl\bindings\soap.py", line 68, in _create
serialized = operation_obj.create(*args, **kwargs)
return self.input.serialize(*args, **kwargs)
File "F:\dev-tools-plugin\Anaconda3\lib\site-packages\zeep\wsdl\messages\soap.py", line 74, in serialize
self.body.render(body, body_value)
File "F:\dev-tools-plugin\Anaconda3\lib\site-packages\zeep\xsd\elements\element.py", line 231, in render
self._render_value_item(parent, value, render_path)
File "F:\dev-tools-plugin\Anaconda3\lib\site-packages\zeep\xsd\elements\element.py", line 255, in _render_value_item
return self.type.render(node, value, None, render_path)
File "F:\dev-tools-plugin\Anaconda3\lib\site-packages\zeep\xsd\types\complex.py", line 279, in render
element.render(parent, element_value, child_path)
File "F:\dev-tools-plugin\Anaconda3\lib\site-packages\zeep\xsd\elements\indicators.py", line 242, in render
element.render(parent, element_value, child_path)
File "F:\dev-tools-plugin\Anaconda3\lib\site-packages\zeep\xsd\elements\element.py", line 231, in render
self._render_value_item(parent, value, render_path)
File "F:\dev-tools-plugin\Anaconda3\lib\site-packages\zeep\xsd\elements\element.py", line 255, in _render_value_item
return self.type.render(node, value, None, render_path)
File "F:\dev-tools-plugin\Anaconda3\lib\site-packages\zeep\xsd\types\complex.py", line 279, in render
element.render(parent, element_value, child_path)
File "F:\dev-tools-plugin\Anaconda3\lib\site-packages\zeep\xsd\elements\indicators.py", line 242, in render
element.render(parent, element_value, child_path)
File "F:\dev-tools-plugin\Anaconda3\lib\site-packages\zeep\xsd\elements\any.py", line 126, in render
self.validate(value, render_path)
File "F:\dev-tools-plugin\Anaconda3\lib\site-packages\zeep\xsd\elements\any.py", line 184, in validate
raise exceptions.ValidationError("Missing element for Any")
zeep.exceptions.ValidationError: Missing element for Any
аспект XLM выглядит следующим образом:
<?xml version='1.0' encoding='utf-8'?>
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
<soap-env:Body>
<ns0:getAllDomains xmlns:ns0="urn:RRAD">
<primary>
<username>user</username>
<password>password</password>
</primary>
<startNumber>0</startNumber>
<conditions>
<item>key1=value</item>
<item>key2=value</item>
<conditions/>
</ns0:getAllDomains>
</soap-env:Body>
</soap-env:Envelope>
кто-нибудь знает, как интегрировать это?
, если это может помочь, тип ожидания (ArrayOfString) со следующей информацией:
ArrayOfStrings({urn:RRAD}ArrayOfStrings(_value_1: string[], arrayType: xsd:string, offset: {http://schemas.xmlsoap.org/soap/encoding/}arrayCoordinate, id: xsd:ID, href: xsd:anyURI, _attr_1: {}))
dict:
{'name': 'ArrayOfStrings', '_element': <Group(<zeep.xsd.elements.indicators.Group object at 0x00000265210B5488>)>, '_attributes': [<Attribute(name='arrayType', type=<zeep.xsd.types.builtins.String object at 0x000002652083F7C8>)>, <Attribute(name='offset', type=<zeep.xsd.dynamic_types.arrayCoordinate object at 0x00000265210AF808>)>, <Attribute(name='id', type=<zeep.xsd.types.builtins.ID object at 0x00000265208494C8>)>, <Attribute(name='href', type=<zeep.xsd.types.builtins.AnyURI object at 0x000002652083FFC8>)>, <zeep.xsd.elements.any.AnyAttribute object at 0x00000265210AF248>], '_restriction': None, '_extension': None, '_extension_types': (), 'qname': <lxml.etree.QName object at 0x0000026521133DE0>, '_resolved': <zeep.xsd.dynamic_types.ArrayOfStrings object at 0x00000265210DD148>, 'is_global': True}
Спасибо!