Я пытаюсь сгенерировать XML для использования веб-службы с ZEEP, но полученный XML-файл недопустим для службы, типы в элементах добавлены неправильно. Как правильно добавить в элементы типы xsi: type = "ns1: Array" / xsi: type = "ns0: string"? или правильно настроить zeep для создания элементов со всеми их атрибутами?.
вот что отправлено:
<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns0="http://www.w3.org/2001/XMLSchema" xmlns:ns1="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns3="http://sandbox.coordinadora.com/agw/ws/guias/1.6/server.php" xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<ns3:Guias_imprimirRotulos>
<p>
<id_rotulo>55</id_rotulo>
<codigos_remisiones/>
<usuario>myuser.ws</usuario>
<clave>6fb1bf6de4550985c</clave>
</p>
</ns3:Guias_imprimirRotulos>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
это мой код:
import zeep
from zeep import Client
from zeep.plugins import HistoryPlugin
from lxml import etree
history = HistoryPlugin()
wsdl = 'http://sandbox.coordinadora.com/agw/ws/guias/1.6/server.php?wsdl'
client = Client(wsdl=wsdl, plugins=[history])
client.set_ns_prefix('SOAP-ENC', 'http://schemas.xmlsoap.org/soap/encoding/')
client.set_ns_prefix('SOAP-ENV', 'http://schemas.xmlsoap.org/soap/envelope/')
client.set_ns_prefix('xsi', 'http://www.w3.org/2001/XMLSchema-instance')
client.set_ns_prefix('ns0', 'http://www.w3.org/2001/XMLSchema')
client.set_ns_prefix('ns1', 'http://schemas.xmlsoap.org/soap/encoding/')
client.set_ns_prefix('ns2', 'http://schemas.xmlsoap.org/soap/envelope/')
client.set_ns_prefix('ns3', 'http://sandbox.coordinadora.com/agw/ws/guias/1.6/server.php')
client.set_ns_prefix('encodingStyle', 'http://schemas.xmlsoap.org/soap/encoding/')
data = {'id_rotulo':'55',
'codigos_remisiones':['68630005830'],
'usuario':'myuser.ws',
'clave':'6fb1bf6de4550985c'
}
client.service.Guias_imprimirRotulos(data)
for hist in [history.last_sent, history.last_received]:
print(etree.tostring(hist["envelope"], encoding="unicode", pretty_print=True))
это то, что должно быть отправлено:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns0="http://www.w3.org/2001/XMLSchema" xmlns:ns1="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns3="http://sandbox.coordinadora.com/agw/ws/guias/1.6/server.php" xmlns:ns2="http://schemas.xmlsoap.org/soap/envelope/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Header/>
<ns2:Body>
<ns3:Guias_imprimirRotulos>
<p xsi:type="ns3:Agw_imprimirRotulosIn">
<id_rotulo xsi:type="ns0:string">55</id_rotulo>
<codigos_remisiones xsi:type="ns1:Array">
<id_remision xsi:type="ns0:string">68630005829</id_remision>
</codigos_remisiones>
<usuario xsi:type="ns0:string">myuser.ws</usuario>
<clave xsi:type="ns0:string">6fb1bf6dc37090a7e4550985c</clave>
</p>
</ns3:Guias_imprimirRotulos>
</ns2:Body>
</SOAP-ENV:Envelope>