title: Adding env:mustUnderstand="1" attribute to Security tag in Header of SOAP request with Ruby Savon Library
body: <p>Using the Savon SOAP library for Ruby, how can I add the common "env:mustUnderstand" attribute to the Security tag in the header of a SOAP request? By default, it isn't included in the tag.</p>
  
  <p>Here is my current test code:</p>
  
  <pre><code>require 'rubygems'
  require 'savon'
  
  client = Savon::Client.new do
    wsdl.document = File.expand_path("../service_wsdl.xml", __FILE__)
  end
  
  client.wsse.credentials "[removed]", "[removed]"
  
  p client.request :get_meta_data    # Server returns 500 error (presumably due to improper header)
  </code></pre>
  
  <p>Here is the XML that is being sent (which doesn't include the mustUnderstand attribute):</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;env:Envelope xmlns:wsdl="urn:wsdl.ws.[removed].com/v1.1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ins0="urn:messages.ws.[removed].com/v1.1" xmlns:ins1="urn:objects.ws.[removed].com/v1.1" xmlns:ins2="urn:base.ws.[removed].com/v1.1" xmlns:ins3="urn:nullfields.ws.[removed].com/v1.1" xmlns:ins4="urn:generic.ws.[removed].com/v1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ins5="urn:metadata.ws.[removed].com/v1.1" xmlns:ins6="urn:faults.ws.[removed].com/v1.1" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"&gt;
  &lt;env:Header&gt;
      &lt;wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"&gt;
          &lt;wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="UsernameToken-1"&gt;
              &lt;wsse:Username&gt;[removed]&lt;/wsse:Username&gt;
              &lt;wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText"&gt;[removed]&lt;/wsse:Password&gt;
              &lt;/wsse:UsernameToken&gt;
          &lt;/wsse:Security&gt;
      &lt;/env:Header&gt;
      &lt;env:Body&gt;
          &lt;GetMetaData/&gt;
      &lt;/env:Body&gt;
  &lt;/env:Envelope&gt;
  </code></pre>