I am writing a SOAP client using the python library suds. The service I use does not provide a WSDL file, so I have to write one by one. I am trying to make a request that takes a variable number of types as parameters.
Currently for a method in WSDL I have the following:
<wsdl:message name="get_usertagRequest">
<wsdl:part name="email" type="xsd:string"
minOccurs="1" maxOccurs="1"/>
<wsdl:part name="tag" type="xsd:string"
minOccurs="0" maxOccurs="unbounded"/>
</wsdl:message>
I can call this with a single tag parameter with the following code:
client = Client(url)
service = client.service['debian.org']
foo = service.get_usertag('someone@debian.org', tag='malloc')
It produces a query that looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:ns3="urn:Debbugs/SOAP" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.w3.org/2001/XMLSchema" xmlns:ns2="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns4="urn:Debbugs/SOAP/TYPES" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Header/>
<ns0:Body>
<ns3:get_usertag>
<email xsi:type="ns1:string">someone@debian.org</email>
<tag xsi:type="ns4:string">malloc</tag>
</ns3:get_usertag>
</ns0:Body>
</SOAP-ENV:Envelope>
How can I change my code or WSDL to create a query that looks like this?
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:ns3="urn:Debbugs/SOAP" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.w3.org/2001/XMLSchema" xmlns:ns2="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns4="urn:Debbugs/SOAP/TYPES" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Header/>
<ns0:Body>
<ns3:get_usertag>
<email xsi:type="ns1:string">someone@debian.org</email>
<tag xsi:type="ns4:string">malloc</tag>
<tag xsi:type="ns4:string">anothertag</tag>
</ns3:get_usertag>
</ns0:Body>
</SOAP-ENV:Envelope>
Updated Attempts
I tried new approaches based on the following answer. Inserting its sentence directly into wsdlleads to wsdl incompatibility:
<xsd:schema targetNamespace="ns6:your_namespace" attributeFormDefault="qualified" elementFormDefault="qualified">
<xsd:element name="tag_list">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="tag" nillable="true" type="ns4:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
Suds throws an exception: Exception: prefix (ns6) not resolved
element complexType :
<wsdl:types>
<schema targetNamespace="urn:Debbugs/SOAP/TYPES"
xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<element name="tag_list">
<complexType>
<sequence>
<element maxOccurs="unbounded" minOccurs="0" name="tag" nillable="true" type="xsd:string" />
</sequence>
</complexType>
</element>
- -
<wsdl:message name="get_usertagRequest">
<wsdl:part name="email" type="xsd:string"
minOccurs="1" maxOccurs="1"/>
<wsdl:part name="tag" element="types:tag_list"
minOccurs="0" maxOccurs="unbounded"/>
:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:ns3="urn:Debbugs/SOAP" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.w3.org/2001/XMLSchema" xmlns:ns2="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns4="urn:Debbugs/SOAP/TYPES" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Header/>
<ns0:Body>
<ns3:get_usertag>
<email xsi:type="ns1:string">someone@debian.org</email>
<tag_list xsi:type="ns4:tag_list">malloc</tag_list>
</ns3:get_usertag>
</ns0:Body>
</SOAP-ENV:Envelope>
, :
suds.WebFault: Server raised fault: 'Application failed during request deserialization: Unrecognized type '{urn:Debbugs/SOAP/TYPES}tag_list'
, suds . wsdl:
foo = service.get_usertag('someone@debian.org', 'malloc', 'foo')
foo = service.get_usertag('someone@debian.org', ['malloc', 'foo'])
wsdl, , .