title: PHP SOAP request to send multiple stdclass objects
body: <p>I am trying to send a PHP SOAP request that has multiple stdclass objects. I cannot figure out how to send so the xml is properly formatted. The xml structure should look like the following (from SOAPui).</p>
  
  <pre><code>    &lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
   xmlns:ass="http://assignment.soap.assignshare" 
   xmlns:xsd="http://request.assignment.soap.assignshare/xsd" 
   xmlns:xsd1="http://datamodel.assignment.soap.assignshare/xsd"&gt;
     &lt;soapenv:Header/&gt;
     &lt;soapenv:Body&gt;
        &lt;ass:SetStaffOnDutyStatus&gt;
           &lt;ass:SasPubSetStaffOnDutyStatus&gt;
              &lt;xsd:Source&gt;VendorC&lt;/xsd:Source&gt;
              &lt;xsd:Dest&gt;?&lt;/xsd:Dest&gt;
              &lt;xsd:PubEventMsgTag&gt;1&lt;/xsd:PubEventMsgTag&gt;
              &lt;xsd:EventSetStaffOnDutyStatus&gt;
                 &lt;xsd:Timestamp&gt;Thurs,03 Nov 2016,20:20:00 GMT&lt;/xsd:Timestamp&gt;
                 &lt;xsd:EventAction&gt;Set&lt;/xsd:EventAction&gt;
                 &lt;xsd:Staff&gt;
                    &lt;xsd1:StaffID&gt;10&lt;/xsd1:StaffID&gt;
                    &lt;xsd1:Last&gt;Doe&lt;/xsd1:Last&gt;
                    &lt;xsd1:First&gt;John&lt;/xsd1:First&gt;
                    &lt;xsd1:Middle&gt;?&lt;/xsd1:Middle&gt;
                    &lt;xsd1:Role&gt;?&lt;/xsd1:Role&gt;
                 &lt;/xsd:Staff&gt;
                 &lt;xsd:Team&gt;
                    &lt;xsd1:TeamID&gt;319&lt;/xsd1:TeamID&gt;
                    &lt;xsd1:TeamName&gt;5 East&lt;/xsd1:TeamName&gt;
                 &lt;/xsd:Team&gt;
              &lt;/xsd:EventSetStaffOnDutyStatus&gt;
           &lt;/ass:SasPubSetStaffOnDutyStatus&gt;
        &lt;/ass:SetStaffOnDutyStatus&gt;
     &lt;/soapenv:Body&gt;
  &lt;/soapenv:Envelope&gt;
  </code></pre>
  
  <p>My PHP file is</p>
  
  <pre><code>&lt;?php
  
      $a = new StdClass();
      $a-&gt;SasPubSetStaffOnDutyStatus = new StdClass();
      $a-&gt;SasPubSetStaffOnDutyStatus-&gt;Source = 'Demo';
      $a-&gt;SasPubSetStaffOnDutyStatus-&gt;Dest = 'http://192.168.50.3:26001/SAIWebService';
      $a-&gt;SasPubSetStaffOnDutyStatus-&gt;PubEventMsgTag = 1;
      $a-&gt;SasPubSetStaffOnDutyStatus-&gt;EventSetStaffOnDutyStatus = new StdClass($b);
  
      $b = new StdClass();
      $b-&gt;EventSetStaffOnDutyStatus = new StdClass();
      $b-&gt;EventSetStaffOnDutyStatus-&gt;Timestamp = 'Thurs,03 Nov 2016,20:20:00 GMT';
      $b-&gt;EventSetStaffOnDutyStatus-&gt;EventAction = 'Set';
  
      $c = new StdClass();
      $c-&gt;Staff = new StdClass();
      $c-&gt;Staff-&gt;StaffID = 10;
      $c-&gt;Staff-&gt;Last = 'Harry';
      $c-&gt;Staff-&gt;First = 'Potter';
      $c-&gt;Staff-&gt;Middle = '?';
      $c-&gt;Staff-&gt;Role = '?';
  
      $d = new StdClass();
      $d-&gt;Team = new StdClass();
      $d-&gt;Team-&gt;TeamID = 319;
      $d-&gt;Team-&gt;TeamName = '5 East';
  
      $d = (object)array_merge ((array)$b, (array)$c, (array)$d);
      $e = (object)array_merge((array)$a, (array)$d);
  
      $wsdl = "http://192.xxx.xx.x:26001/SAIWebservice?singlewsdl";
  
      $client = new SoapClient($wsdl, array(
                              "trace"=&gt;1,
                              "exceptions"=&gt;0));
  
      $values = $client-&gt;SetStaffOnDutyStatus($e);
      echo "REQUEST HEADERS:\n" . $client-&gt;__getLastRequestHeaders() . "\n";
  
      $xml = $values-&gt;SasPubRespSetStaffOnDutyStatus;
      print "&lt;pre&gt;\n";
      print_r($xml);
      print "&lt;/pre&gt;";
  </code></pre>
  
  <p>The output of the PHP file does not include the values of objects $b, $c &amp; $d. Appreciate any guidance on what I'm doing wrong to merge the objects. Output is below.</p>
  
  <pre><code>    &lt;SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:ns1="http://request.assignment.soap.assignshare/xsd"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:ns2="http://assignment.soap.assignshare"&gt;
   &lt;SOAP-ENV:Body&gt;
      &lt;ns2:SetStaffOnDutyStatus&gt;
          &lt;ns2:SasPubSetStaffOnDutyStatus&gt;
              &lt;ns1:Source&gt;Demo&lt;/ns1:Source&gt;
              &lt;ns1:Dest&gt;http://192.168.50.3:26001/SAIWebService&lt;/ns1:Dest&gt;
              &lt;ns1:PubEventMsgTag&gt;1&lt;/ns1:PubEventMsgTag&gt;
              &lt;ns1:EventSetStaffOnDutyStatus&gt;
              &lt;ns1:Timestamp xsi:nil="true"/&gt;
              &lt;ns1:EventAction xsi:nil="true"/&gt;
              &lt;ns1:Staff xsi:nil="true"/&gt;
              &lt;ns1:Team xsi:nil="true"/&gt;
              &lt;/ns1:EventSetStaffOnDutyStatus&gt;
          &lt;/ns2:SasPubSetStaffOnDutyStatus&gt;
      &lt;/ns2:SetStaffOnDutyStatus&gt;
  &lt;/SOAP-ENV:Body&gt;&lt;/SOAP-ENV:Envelope&gt;
  </code></pre>