Sending the same type multiple times in a SOAP request using foam

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:

# only malloc is sent in the request
foo = service.get_usertag('someone@debian.org', 'malloc', 'foo')

# results in suds.TypeNotFound: Type not found: 'tag_list'
foo = service.get_usertag('someone@debian.org', ['malloc', 'foo'])

wsdl, , .

+4
2

, , . SOAP.pm. get_usertag, :

 my %ut = get_usertag('don@donarmstrong.com','this-bug-sucks','eat-this-bug');
 my %ut = get_usertag('don@donarmstrong.com');

, - , . (complexType) , .

SOAP:: Lite, :

  • , ( , , SOAP:: Data).
  • WSDL.

, SOAP:: Data. ( - ). ( ...) . SOAP:: WSDL SOAP:: Lite.

, , . , / ( , ), , SOAP:: - .

WSDL. . , get_usertag ( Perl, ). $email @tags. $email $tag_list. $tag_list @tags .


WSDL WSDL. , . . . WSDL:

<wsdl:types>

    <xsd:schema  targetNamespace="urn:Debbugs/SOAP" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="qualified">

    <xsd:element name="get_usertagResponse" >
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="msg" minOccurs="0" maxOccurs="unbounded"  type="xsd:string" />
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
<!--The new Tag_lis element-->
      <xsd:element name="Tag_list" >
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="tag" minOccurs="0" maxOccurs="unbounded"  type="xsd:string" />
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
    </xsd:schema>

  </wsdl:types>
<!--get_usertagRequest use Tag_lis element-->
  <wsdl:message name="get_usertagRequest">
    <wsdl:part name="email" type="xsd:string"/>
    <wsdl:part name="tag_list" element="tns:Tag_list"/>
  </wsdl:message>

  <wsdl:message name="get_usertagResponse">
    <wsdl:part name="msg" type="tns:get_usertagResponse"/>
  </wsdl:message>

, WSDL. , . , soapUi. :

<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="urn:Debbugs/SOAP">
   <soapenv:Header/>
   <soapenv:Body>
      <soap:get_usertag soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
         <email xsi:type="xsd:string">?</email>
         <soap:Tag_list>
            <!--Zero or more repetitions:-->
            <tag xsi:type="xsd:string">?</tag>
         </soap:Tag_list>
      </soap:get_usertag>
   </soapenv:Body>
</soapenv:Envelope>

:

client = Client(url)
service = client.service['debian.org']
foo = service.get_usertag('someone@debian.org', tag_list=['malloc', 'amother'])
0
 client = Client(url)
 //forming request
arrayoftagList = client.factory.create('ArrayOfString')
arrayoftagList.tag_list = [malloc,anothertag]
print client.service.get_usertag(someone@debian.org, arrayoftagList).string

:

wsdl:

wsdl, tagRequest,

<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:part name="tag_list" type="types:ArrayOfString"
           minOccurs="0" maxOccurs="unbounded"/>

, : ArrayOfString,

<complexType name="ArrayOfString">
     <sequence>
       <element minOccurs="0" maxOccurs="unbounded"
                name="string" nillable="true"
                type="xsd:string"/>
     </sequence>
   </complexType>

, :

 client = Client(url)
 //forming request
arrayoftagList = client.factory.create('ArrayOfString')
arrayoftagList.string = [malloc,anothertag]
print client.service.get_usertag(someone@debian.org, arrayoftagList).string

, ( , )

  <get_usertag>
     <email>someone@debian.org</email>
     <string>malloc</string>
     <string>anothertag</string>
  </get_usertag>

, "" , wsdl,

   <complexType name="ArrayOfString">
     <sequence>
       <element minOccurs="0" maxOccurs="unbounded"
                name="tag" nillable="true"
                type="xsd:string"/>
     </sequence>
   </complexType>

:

, wsdl:

wsdl get_Usertag, , wsdl. wsdl .

   <?xml version="1.0" encoding="UTF-8"?>


<wsdl:definitions
    name="Debbugs/SOAP"
    targetNamespace="urn:Debbugs/SOAP"
    xmlns:tns="urn:Debbugs/SOAP"
    xmlns:types="urn:Debbugs/SOAP/TYPES"
    xmlns:apachens="http://xml.apache.org/xml-soap"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
    soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">

  <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="UsertagRequest">
           <complexType>
            <sequence>
           <element name="email" type="xsd:string"
                    minOccurs="1" MaxOccurs="1"/>
           <element name="tag" type="xsd:string"
                    minOccurs="0" MaxOccurs="unbounded"/>
         </sequence>
       </complexType>
       </element>
    </schema>
  </wsdl:types>

  <wsdl:message name="get_usertagRequest">
    <wsdl:part name = "parameters" element="types:UsertagRequest"/>
  </wsdl:message>
  <wsdl:message name="get_usertagResponse">
    <wsdl:part name="s-gensym3" type="xsd:string"/>
  </wsdl:message>


  <wsdl:portType name="Debbugs/SOAP">
    <wsdl:operation name="get_usertag">
      <wsdl:input message="tns:get_usertagRequest">
        <soap:body
        encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
        namespace="urn:Debbugs/SOAP"
        use="encoded"/>
      </wsdl:input>
      <wsdl:output message="tns:get_usertagResponse">
        <soap:body
        encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
        namespace="urn:Debbugs/SOAP"
        use="encoded"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:portType>

  <wsdl:binding name="Debbugs/SOAP/BINDING" type="tns:Debbugs/SOAP">
    <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="get_usertag">
      <wsdl:input message="tns:get_usertagRequest">
        <soap:body
        encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
        namespace="urn:Debbugs/SOAP"
        use="encoded"/>
      </wsdl:input>
      <wsdl:output message="tns:get_usertagResponse">
        <soap:body
        encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
        namespace="urn:Debbugs/SOAP"
        use="encoded"/>
      </wsdl:output>
    </wsdl:operation>

  </wsdl:binding>

  <wsdl:service name="Debbugs/SOAP/SERVICE">
    <wsdl:port binding="tns:Debbugs/SOAP/BINDING" name="gnu.org">
      <wsdlsoap:address location="http://debbugs.gnu.org/cgi/soap.cgi"/>
    </wsdl:port>
    <wsdl:port binding="tns:Debbugs/SOAP/BINDING" name="debian.org">
      <wsdlsoap:address location="http://bugs.debian.org/cgi-bin/soap.cgi"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

wsdl , ,

    <soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="urn:Debbugs/SOAP" xmlns:typ="urn:Debbugs/SOAP/TYPES">
   <soapenv:Header/>
   <soapenv:Body>
      <soap:get_usertag soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
         <typ:UsertagRequest>
            <email xsi:type="xsd:string">?</email>
            <!--Optional:-->
            <tag xsi:type="xsd:string">?</tag>
         </typ:UsertagRequest>
      </soap:get_usertag>
   </soapenv:Body>
</soapenv:Envelope>
0

All Articles