title: Python Zeep SOAP client module - can't set attributes for an element
body: <p>I'm a little bit rusted with Python but I need to set up a SOAP call with zeep client. I managed to successfully call a couple of methods by passing in only a dictionary object but I don't have luck setting this one part and I'm not sure if it's even possible using this technique.</p>
  
  <p>This is the part of the envelope I have trouble with:</p>
  
  <pre><code>&lt;xs:complexType name="setupParameter"&gt;
      &lt;xs:sequence /&gt;
      &lt;xs:attribute name="key" type="xs:string" use="required" /&gt;
      &lt;xs:attribute name="value" type="xs:string" use="required" /&gt;
  &lt;/xs:complexType&gt;
  </code></pre>
  
  <p>which is embedded inside:</p>
  
  <pre><code>&lt;xs:complexType name="transportSettings"&gt;
      &lt;xs:sequence&gt;
          &lt;xs:element maxOccurs="unbounded" minOccurs="0" name="setupParameter" type="tns:setupParameter" /&gt;
      &lt;/xs:sequence&gt;
  &lt;/xs:complexType&gt;
  </code></pre>
  
  <p>I tried passing this params like this:</p>
  
  <pre><code>'transportSettings': {
      [
          {'setupParameter': {'key': 'key1', 'value': 'val1'}},
          {'setupParameter': {'key': 'key2', 'value': 'val2'}}
      ]
   }
  </code></pre>
  
  <p>inside the envelope but it seems that it's not working.
  Since the SOAP method does not have great validation it does create two items of <code>setupParameter</code> type but they both are missing <code>key</code> and <code>value</code> values.</p>
  
  <p>Shed some light onto this for me, please.</p>
  
  <p><strong>Edit1</strong></p>
  
  <p>This is the output from SoapUI (part of the request) that I'm trying to replicate:</p>
  
  <pre><code>&lt;transportSettings&gt;
      &lt;!--Zero or more repetitions:--&gt;
      &lt;setupParameter key="?" value="?"/&gt;
  &lt;/transportSettings&gt;
  </code></pre>
  
  <p><strong>Edit2</strong></p>
  
  <p>So, I've added a plugin to zeep client (as described in their documentation) that prints out SOAP requests and responses and this is the request:</p>
  
  <pre><code>&lt;soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"&gt;
    &lt;soap-env:Body&gt;
      &lt;ns0:provisionService xmlns:ns0="http://ntc.nms.slm.hub.provisioning"&gt;
        &lt;service&gt;
          &lt;vn&gt;test&lt;/vn&gt;
          &lt;serviceClass&gt;Satellite Internet Access - 3100 Forward&lt;/serviceClass&gt;
          &lt;linkType&gt;MULTIPLE_ACCESS&lt;/linkType&gt;
          &lt;channelCarrier&gt;false&lt;/channelCarrier&gt;
          &lt;transportSettings&gt;
            &lt;setupParameter key="" value=""/&gt;
          &lt;/transportSettings&gt;
          &lt;multicastRequired&gt;false&lt;/multicastRequired&gt;
          &lt;linkTopology&gt;POINT_TO_POINT&lt;/linkTopology&gt;
          &lt;serviceGuiOptions&gt;
            &lt;enableBooking&gt;true&lt;/enableBooking&gt;
            &lt;enableUnManagedTransmitter&gt;false&lt;/enableUnManagedTransmitter&gt;
            &lt;enableCustomSetupParameters&gt;true&lt;/enableCustomSetupParameters&gt;
          &lt;/serviceGuiOptions&gt;
          &lt;qosParameters&gt;
            &lt;bestEffortPirFixed&gt;0&lt;/bestEffortPirFixed&gt;
            &lt;bestEffortPirPct&gt;0&lt;/bestEffortPirPct&gt;
            &lt;criticalData1CirFixed&gt;0&lt;/criticalData1CirFixed&gt;
            &lt;criticalData1CirPct&gt;0&lt;/criticalData1CirPct&gt;
            &lt;criticalData1PirFixed&gt;0&lt;/criticalData1PirFixed&gt;
            &lt;criticalData1PirPct&gt;0&lt;/criticalData1PirPct&gt;
            &lt;criticalData2CirFixed&gt;0&lt;/criticalData2CirFixed&gt;
            &lt;criticalData2CirPct&gt;0&lt;/criticalData2CirPct&gt;
            &lt;criticalData2PirFixed&gt;0&lt;/criticalData2PirFixed&gt;
            &lt;criticalData2PirPct&gt;0&lt;/criticalData2PirPct&gt;
            &lt;criticalData3CirFixed&gt;0&lt;/criticalData3CirFixed&gt;
            &lt;criticalData3CirPct&gt;0&lt;/criticalData3CirPct&gt;
            &lt;criticalData3PirFixed&gt;0&lt;/criticalData3PirFixed&gt;
            &lt;criticalData3PirPct&gt;0&lt;/criticalData3PirPct&gt;
            &lt;realTime1CirFixed&gt;6000&lt;/realTime1CirFixed&gt;
            &lt;realTime1CirPct&gt;0&lt;/realTime1CirPct&gt;
            &lt;realTime2CirFixed&gt;0&lt;/realTime2CirFixed&gt;
            &lt;realTime2CirPct&gt;0&lt;/realTime2CirPct&gt;
            &lt;realTime3CirFixed&gt;0&lt;/realTime3CirFixed&gt;
            &lt;realTime3CirPct&gt;80&lt;/realTime3CirPct&gt;
          &lt;/qosParameters&gt;
        &lt;/service&gt;
      &lt;/ns0:provisionService&gt;
    &lt;/soap-env:Body&gt;
  &lt;/soap-env:Envelope&gt;
  </code></pre>
  
  <p>that is created from this input dictionary (by passing in like this - <code>client.service.serviceName(inputDict)</code>):</p>
  
  <pre><code>{
      'serviceClass': '${serviceName}',
      'vn': '${testVnName}',
      'linkType': 'MULTIPLE_ACCESS',
      'linkTopology': 'POINT_TO_POINT',
      'serviceGuiOptions': {
          'enableBooking': 1, 
          'enableUnManagedTransmitter': 0, 
          'enableCustomSetupParameters': 1
      }, 
      'multicastRequired': 0, 
      'channelCarrier': 0, 
      'qosParameters': {
          'realTime1CirFixed': 6000,
          'realTime1CirPct': 0, 
          'realTime2CirFixed': 0, 
          'realTime2CirPct': 0, 
          'realTime3CirFixed': 0, 
          'realTime3CirPct': 80,
          'criticalData1CirFixed': 0, 
          'criticalData1CirPct': 0, 
          'criticalData1PirFixed': 0, 
          'criticalData1PirPct': 0, 
          'criticalData2CirFixed': 0, 
          'criticalData2CirPct': 0, 
          'criticalData2PirFixed': 0, 
          'criticalData2PirPct': 0, 
          'criticalData3CirFixed': 0, 
          'criticalData3CirPct': 0, 
          'criticalData3PirFixed': 0, 
          'criticalData3PirPct': 0, 
          'bestEffortPirFixed': 0, 
          'bestEffortPirPct': 0
      }, 
      'transportSettings': [
          {'setupParameter': {'key': 'forwardGateway', 'value': 'dialog'}}, 
          {'setupParameter': {'key': 'referenceServiceProfileDomainName', 'value': 'hno'}}
      ]
  }
  </code></pre>
  
  <p>And what I want is (just the problematic part):</p>
  
  <pre><code>        &lt;transportSettings&gt;
            &lt;setupParameter key="key1" value="val1"/&gt;
            &lt;setupParameter key="key2" value="val2"/&gt;
            &lt;setupParameter key="key3" value="val3"/&gt;
          &lt;/transportSettings&gt;
  </code></pre>