Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I figured the answer myself after searching the internet.</p> <p>Following is the code to create a complex data type. Here I am creating a datatype Person whch has firstname, age and gender as its data members.</p> <pre class="lang-php prettyprint-override"><code>$server-&gt;wsdl-&gt;addComplexType( 'Person', 'complexType', 'struct', 'all', '', array( 'firstname' =&gt; array('name' =&gt; 'firstname', 'type' =&gt; 'xsd:string'), 'age' =&gt; array('name' =&gt; 'age', 'type' =&gt; 'xsd:int'), 'gender' =&gt; array('name' =&gt; 'gender', 'type' =&gt; 'xsd:string') ) ); </code></pre> <p>Next we must create another new datatype which is an array of the datatype we have created. I call it the person array and the code for it is below:</p> <pre class="lang-php prettyprint-override"><code>$server-&gt;wsdl-&gt;addComplexType( 'PersonArray', // Name 'complexType', // Type Class 'array', // PHP Type '', // Compositor 'SOAP-ENC:Array', // Restricted Base array(), array( array('ref' =&gt; 'SOAP-ENC:arrayType', 'wsdl:arrayType' =&gt; 'tns:Person[]') ), 'tns:Person' ); </code></pre> <p>Now I registered a function called getPeople which takes no input parameters but return an array of persons as:</p> <pre class="lang-php prettyprint-override"><code>$server-&gt;register( 'getPeople', // method name array(), // input parameters array('return' =&gt; 'tns:PersonArray'), // output parameters 'urn:hellowsdl2', // namespace 'urn:hellowsdl2#getPeople', // soapaction 'rpc', // style 'encoded', // use 'Return an array of people' // documentation ); </code></pre> <p>and programmed the function to return some dummy data as:</p> <pre class="lang-php prettyprint-override"><code>function getPeople() { $peopleArray = array(); $peopleArray[] = array( 'firstname' =&gt; "Anand", 'age' =&gt; 25, 'gender' =&gt; "Male" ); $peopleArray[] = array( 'firstname' =&gt; "Sandhya", 'age' =&gt; 21, 'gender' =&gt; "Female" ); return $peopleArray; } </code></pre> <p>by the way I am sorry I haven't mentioned but all this code is in PHP.</p> <p>Hope this helps someone.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload