title: Unable to set attributes on PHP soapvar
body: <p>This question has been asked many times, but there is no convincing answer yet. I am trying to generate xml that looks like this:</p>
  
  <pre><code>&lt;parameters&gt;
     &lt;createUser version='3.0'&gt;
        &lt;name&gt;Batman&lt;/name&gt;
     &lt;/createUser&gt;
  &lt;/parameters&gt;
  </code></pre>
  
  <p>My code is:</p>
  
  <pre><code>$createUser = new \stdClass();
  $createUser-&gt;version = '3.0';
  $createUser-&gt;name = 'Batman';
  $parameters-&gt;createUser = new \SoapVar($createUser, SOAP_ENC_OBJECT);
  $soapRequest = new \SoapVar($parameters,SOAP_ENC_OBJECT, 
      NULL, $typeNamespace, 'createUser');
  
  $response = $soapClient-&gt;__soapCall('submit', 
      array('parameters' =&gt; $soapRequest));
  </code></pre>
  
  <p>And the response I get, of course, is:</p>
  
  <pre><code>&lt;parameters&gt;
     &lt;createUser&gt;
        &lt;version&gt;3.0&lt;/version&gt;
        &lt;name&gt;Batman&lt;/name&gt;
     &lt;/createUser&gt;
  &lt;/parameters&gt;
  </code></pre>
  
  <p>I don't know why Soapvar doesn't provide a way to specify attributes. The answer given in this thread <a href="https://stackoverflow.com/questions/2257973/how-to-add-attributes-to-soapvars">How to add attributes to soapVars</a> doesn't seem to work. The question seems to be doing a lot of rounds:</p>
  
  <p>1: <a href="https://stackoverflow.com/questions/7223896/php-soapvar-object-attribute">PHP SoapVar Object Attribute?</a></p>
  
  <p>2: <a href="https://stackoverflow.com/questions/1327151/soap-request-with-attribute">SOAP request with attribute</a></p>
  
  <p>But there is no concrete answer yet. Does anyone know the right way to get this done?</p>