title: Adding an optional attribute to element in Zeep
body: <p>I am attempting to call a Workday SOAP service using Zeep.</p>
  
  <p>I am able to successfully call the service, add elements to filter the request, and get a response, but I need to specify a version attribute in the request element, and I cannot figure out how to add it:</p>
  
  <pre><code>service = client.create_service(
          '{urn:com.workday/bsvc/'+Human_Resources+'}'+Human_Resources+'Binding',
          'http://my-endpoint.com')
  
  service_operation = 'Get_Job_Profiles'
  
  request_filter = {'Response_Filter' : {
            'Page': 1,
            'Count' : 100, }}
  #other things are added to the request_filter dict as well
  
  response = getattr(service,service_operation)(**request_filter)
  </code></pre>
  
  <p>And this works fine. Zeep produces:</p>
  
  <pre><code>&lt;soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"&gt;
      &lt;soap-env:Header&gt;
          &lt;ns0:Workday_Common_Header xmlns:ns0="urn:com.workday/bsvc"&gt;
              &lt;ns0:Include_Reference_Descriptors_In_Response&gt;true&lt;/ns0:Include_Reference_Descriptors_In_Response&gt;
          &lt;/ns0:Workday_Common_Header&gt;
  # some other security related headers here #
      &lt;/soap-env:Header&gt;
      &lt;soap-env:Body xmlns:ns0="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" ns0:Id="id-3b0aa2ca-dc0f-417c-9168-498275645b16"&gt;
          &lt;ns0:Get_Job_Profiles_Request xmlns:ns0="urn:com.workday/bsvc"&gt;
              &lt;ns0:Request_Criteria&gt;
                  &lt;ns0:Transaction_Log_Criteria_Data&gt;
                      &lt;ns0:Transaction_Date_Range_Data&gt;
                          &lt;ns0:Updated_From&gt;2000-01-01T00:00:00&lt;/ns0:Updated_From&gt;
                          &lt;ns0:Updated_Through&gt;2018-05-09T00:00:00&lt;/ns0:Updated_Through&gt;
                      &lt;/ns0:Transaction_Date_Range_Data&gt;
                  &lt;/ns0:Transaction_Log_Criteria_Data&gt;
              &lt;/ns0:Request_Criteria&gt;
              &lt;ns0:Response_Filter&gt;
                  &lt;ns0:As_Of_Entry_DateTime&gt;2018-05-09T00:00:00&lt;/ns0:As_Of_Entry_DateTime&gt;
                  &lt;ns0:Page&gt;2&lt;/ns0:Page&gt;
                  &lt;ns0:Count&gt;100&lt;/ns0:Count&gt;
              &lt;/ns0:Response_Filter&gt;
              &lt;ns0:Response_Group&gt;
                  &lt;ns0:Include_Reference&gt;true&lt;/ns0:Include_Reference&gt;
                  &lt;ns0:Include_Job_Profile_Basic_Data&gt;true&lt;/ns0:Include_Job_Profile_Basic_Data&gt;
                  &lt;ns0:Include_Job_Classification_Data&gt;true&lt;/ns0:Include_Job_Classification_Data&gt;
                  &lt;ns0:Include_Workers_Compensation_Data&gt;true&lt;/ns0:Include_Workers_Compensation_Data&gt;
                  &lt;ns0:Include_Job_Profile_Compensation_Data&gt;true&lt;/ns0:Include_Job_Profile_Compensation_Data&gt;
              &lt;/ns0:Response_Group&gt;
          &lt;/ns0:Get_Job_Profiles_Request&gt;
      &lt;/soap-env:Body&gt;
  &lt;/soap-env:Envelope&gt;
  </code></pre>
  
  <p>But now I need to add an attribute to:</p>
  
  <pre><code>&lt;ns0:Get_Job_Profiles_Request xmlns:ns0="urn:com.workday/bsvc"&gt;
  </code></pre>
  
  <p>It needs to look like something like this:</p>
  
  <pre><code>&lt;ns0:Get_Job_Profiles_Request xmlns:ns0="urn:com.workday/bsvc" ns0:version="v29"&gt;
  </code></pre>
  
  <p>Here is the definition from the xsd:</p>
  
  <pre><code>&lt;xsd:complexType name="Get_Job_Profiles_RequestType"&gt;
  &lt;xsd:annotation&gt;
      &lt;xsd:documentation&gt;Request element used to find and get Job Profiles and their associated data.&lt;/xsd:documentation&gt;
  &lt;/xsd:annotation&gt;
  &lt;xsd:sequence&gt;
      &lt;xsd:element name="Request_References" type="wd:Job_Profile_Request_ReferencesType" minOccurs="0"/&gt;
      &lt;xsd:element name="Request_Criteria" type="wd:Job_Profile_Request_CriteriaType" minOccurs="0"/&gt;
      &lt;xsd:element name="Response_Filter" type="wd:Response_FilterType" minOccurs="0"/&gt;
      &lt;xsd:element name="Response_Group" type="wd:Job_Profile_Response_GroupType" minOccurs="0"/&gt;
  &lt;/xsd:sequence&gt;
  &lt;xsd:attribute ref="wd:version"/&gt;&lt;/xsd:complexType&gt;
  </code></pre>
  
  <p>It's easy enough to add an element and a value, but I am stumped on how to add an attribute to an element. </p>