title: How do you pass an object parameter to a SOAP method call in PHP?
body: <p>I'm trying to make a soap request and the method I'm calling takes any number of objects define by this:</p>
  
  <pre><code>&lt;xs:complexType name="thing"&gt;
    &lt;xs:sequence&gt;
      &lt;xs:element minOccurs="0" name="string1" type="xs:string"/&gt;
      &lt;xs:element minOccurs="0" name="string2" type="xs:string"/&gt;
      &lt;xs:element minOccurs="0" name="string3" type="xs:long"/&gt;
    &lt;/xs:sequence&gt;
  &lt;/xs:complexType&gt;
  </code></pre>
  
  <p>How do I create an object like that in PHP and pass it to the soap method? Right now the (not working) code I have looks like this:</p>
  
  <pre><code>$obj-&gt;string1 = 'something';
  $obj-&gt;string2 = 'something';
  $obj-&gt;string3 = 'something';
  $param = new SoapParam(new SoapVar($obj, SOAP_ENC_OBJECT, 'method', 'http://ns'), 'paramName');
  
  $soapClient-&gt;method($param);
  </code></pre>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>This is the body of the request of the shown method:</p>
  
  <pre><code>&lt;SOAP-ENV:Body&gt;
    &lt;ns2:method xsi:type="ns1:method"&gt;
      &lt;string1&gt;something&lt;/string1&gt;
      &lt;string2&gt;something&lt;/string2&gt;
      &lt;string3&gt;something&lt;/string3&gt;
    &lt;/ns2:placeHolds&gt;
  &lt;/SOAP-ENV:Body&gt;
  </code></pre>
  
  <p>If I just pass $obj instead of creating a SoapParam, this is the body in the request:</p>
  
  <pre><code>&lt;SOAP-ENV:Body&gt;
    &lt;ns1:method/&gt;
  &lt;/SOAP-ENV:Body&gt;
  </code></pre>