title: wsdl return an array of complex types
body: <p>I have defined a web service that will return the data from my mysql data base.</p>
  
  <p>I have written the web service in php.</p>
  
  <p>Now I have defined a complex type as follows:</p>
  
  <pre><code>$server-&gt;wsdl-&gt;addComplexType(
  'Category',
  'complexType',
  'struct',
  'all',
  '',
  array(
      'category_parent_id' =&gt; array('name' =&gt; 'category_parent_id', 'type' =&gt; 'xsd:int'),
      'category_child_id' =&gt; array('name' =&gt; 'category_child_id', 'type' =&gt; 'xsd:int'),
      'category_list' =&gt; array('name' =&gt; 'category_list', 'type' =&gt; 'xsd:int')
  )
  </code></pre>
  
  <p>);</p>
  
  <p>The above complex type is a row in a table in my database.</p>
  
  <p>Now my function must send an array of these rows so how do I achieve the same</p>
  
  <p>My code is as follows:</p>
  
  <pre><code>require_once('./nusoap/nusoap.php');
  $server = new soap_server;
  
  $server-&gt;configureWSDL('productwsdl', 'urn:productwsdl');
  
  // Register the data structures used by the service
  $server-&gt;wsdl-&gt;addComplexType(
      'Category',
      'complexType',
      'struct',
      'all',
      '',
      array(
          'category_parent_id' =&gt; array('name' =&gt; 'category_parent_id', 'type' =&gt; 'xsd:int'),
          'category_child_id' =&gt; array('name' =&gt; 'category_child_id', 'type' =&gt; 'xsd:int'),
          'category_list' =&gt; array('name' =&gt; 'category_list', 'type' =&gt; 'xsd:int')
      )
  );
  $server-&gt;register('getaproduct',                    // method name
      array(),          // input parameters
      //array('return' =&gt; array('result' =&gt; 'tns:Category')),    // output parameters
      array('return' =&gt;  'tns:Category'),    // output parameters
      'urn:productwsdl',                         // namespace
      'urn:productwsdl#getaproduct',                   // soapaction
      'rpc',                                    // style
      'encoded',                                // use
      'Get the product categories'        // documentation
  );
  
  function getaproduct()
  {
      $conn = mysql_connect('localhost','root','');
       mysql_select_db('sssl', $conn);
       $sql = "SELECT * FROM jos_vm_category_xref";
       $q = mysql_query($sql);
       while($r = mysql_fetch_array($q))
       {
           $items[] = array('category_parent_id'=&gt;$r['category_parent_id'],
                                'category_child_id'=&gt;$r['category_child_id'],
                                'category_list'=&gt;$r['category_list']);
       }
         return $items;
  }
  
  
      // Use the request to (try to) invoke the service
  $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
  $server-&gt;service($HTTP_RAW_POST_DATA);
  </code></pre>