title: Returning a PHP Array from a PHP SoapServer
body: <p>I'm relatively new to Soap on the "creating the service side", so appologies in advance for any terminology I'm munging.</p>
  
  <p>Is it possible to return a PHP array from a Remote Procedure Soap Service that's been setup using PHP's SoapServer Class?</p>
  
  <p>I have a WSDL (built by blindly following a tutorial) that, in part, looks something like this</p>
  
  <pre><code>&lt;message name='genericString'&gt;
      &lt;part name='Result' type='xsd:string'/&gt;
  &lt;/message&gt;
  
  &lt;message name='genericObject'&gt;
      &lt;part name='Result' type='xsd:object'/&gt;
  &lt;/message&gt;
  
  &lt;portType name='FtaPortType'&gt;       
      &lt;operation name='query'&gt;
          &lt;input message='tns:genericString'/&gt;
          &lt;output message='tns:genericObject'/&gt;
      &lt;/operation&gt;        
  &lt;/portType&gt;
  </code></pre>
  
  <p>The PHP method I'm calling is named query, and looks something like this </p>
  
  <pre><code>public function query($arg){
      $object = new stdClass();
      $object-&gt;testing = $arg;
      return $object;     
  }
  </code></pre>
  
  <p>This allows me to call </p>
  
  <pre><code>$client = new SoapClient("http://example.com/my.wsdl");
  $result = $client-&gt;query('This is a test');
  </code></pre>
  
  <p>and dump of result will look something like</p>
  
  <pre><code>object(stdClass)[2]
      public 'result' =&gt; string 'This is a test' (length=18)
  </code></pre>
  
  <p>I want to return a native PHP array/collection from my query method.  If I change my query method to return an array</p>
  
  <pre><code>public function query($arg) {
      $object = array('test','again');
      return $object;
  }
  </code></pre>
  
  <p>It's serialized into an object on the client side.</p>
  
  <pre><code>object(stdClass)[2]
      public 'item' =&gt; 
          array
              0 =&gt; string 'test' (length=4)
              1 =&gt; string 'again' (length=5)
  </code></pre>
  
  <p>This makes sense, as I've specific a <code>xsd:object</code> as the Result type in my WSDL.  I'd like to, if possible,  return an native PHP array that's not wrapped in an Object.  My instincts say there's a specific xsd:type that will let me accomplish this, but I don't know.  I'd also settle for the object being serialized as an <code>ArrayObject</code>.</p>
  
  <p>Don't hold back on schooling me in the technical details os WSDL.  I'm trying to get a grasp on the underlying concepts fo</p>