title: WSDL PHP function returns null while other function returns expected result
body: <p><strong>Summary</strong></p>
  
  <p>Here I'll list all steps I've taken to solve this problem as reference for others.</p>
  
  <p>1.
  PHP, stupidly enough, 'listens' to the input message of a function to define what function it should use. So give every one of your functions a different input message, even though it uses the same type or element. You may think this is quite some work for you to solve but it can be done like this:</p>
  
  <pre><code>&lt;xsi:complexType name="UserCredentials"&gt;
  &lt;xsi:attribute name="customerID" type="xsi:int"/&gt;
  &lt;/xsi:complexType&gt;
  
  &lt;xsi:element name="UserCredentials" type="types:UserCredentials"/&gt;
  &lt;xsi:element name="UserCredentials1" type="types:UserCredentials"/&gt;
  
  &lt;wsdl:message name="getCustomerCredentials"&gt;
   &lt;wsdl:part name="body" element="types:UserCredentials"/&gt;
  &lt;/wsdl:message&gt;
  &lt;wsdl:message name="getCustomerCredentials1"&gt;
  &lt;wsdl:part name="body" element="types:UserCredentials1"/&gt;
  &lt;/wsdl:message&gt;
  </code></pre>
  
  <p>Next, Visual Studio was whining, I spend a couple of days figuring this stupidly idiotic simple thing out, just tell the program you have just set the objects property:</p>
  
  <pre><code> UserCredentials.customerID = User.CustomerID;
   UserCredentials.customerIDSpecified = true;
  </code></pre>
  
  <p>And that's it. I can't believe it myself. I spend 1,5 weeks, solution is two steps, please give this guy who answered below some votes up.</p>
  
  <p><strong>Update</strong></p>
  
  <p>My input object is NOT begin parsed into XML.</p>
  
  <p>//Fix:</p>
  
  <p>You have to tell the program that the property is set like so:</p>
  
  <pre><code>UserCredentials.customerID = User.CustomerID;
  UserCredentials.customerIDSpecified = true;
  </code></pre>
  
  <p>Fiddler shows this:</p>
  
  <p>Input</p>
  
  <pre><code>&lt;s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"&gt;
  &lt;s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
  &lt;UserCredentials2 xmlns="http://5.157.80.21/servicehandler/wsdl_service.wsdl"/&gt;   
  &lt;/s:Body&gt;
  &lt;/s:Envelope&gt;
  </code></pre>
  
  <p>Output</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; 
  &lt;SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="types"&gt;
  &lt;SOAP-ENV:Body&gt;
  &lt;ns1:PersoonArray/&gt;
  &lt;/SOAP-ENV:Body&gt;
  &lt;/SOAP-ENV:E‌​nvelope&gt;
  </code></pre>
  
  <p>Is there something wrong with this code?</p>
  
  <pre><code>    public static List&lt;Klant&gt; GetAllPersonen()
      {
          List&lt;Klant&gt; list = new List&lt;Klant&gt;();
  
          WeGotchaService.Persoon[] servicePersonen = dpc.getAllPersoonData(UserCredentials);
  
          foreach (WeGotchaService.Persoon p in servicePersonen)
          {
              Klant k = new Klant(p);
              list.Add(k);
          }
  
          return list;
      }
  </code></pre>
  
  <p><strong>Update to comment below</strong></p>
  
  <pre><code>&lt;xsi:complexType name="UserCredentials"&gt;
          &lt;xsi:attribute name="customerID" type="xsi:int"/&gt;       
      &lt;/xsi:complexType&gt;
          &lt;xsi:element name="UserCredentials" type="tns:UserCredentials" /&gt;
          &lt;xsi:element name="UserCredentials2" type="tns:UserCredentials"/&gt;
  
   &lt;wsdl:message name="getCustomerCredentials"&gt;
      &lt;wsdl:part name="body" element="ns:UserCredentials"/&gt;
  &lt;/wsdl:message&gt;
  &lt;wsdl:message name="getCustomerCredentials2"&gt;
      &lt;wsdl:part name="body" element="ns:UserCredentials2"/&gt;
  &lt;/wsdl:message&gt;
  
      &lt;wsdl:operation name="getAllLessenData"&gt;
          &lt;wsdl:input message="ns:getCustomerCredentials"/&gt;
          &lt;wsdl:output message="ns2:LessenList"/&gt;
      &lt;/wsdl:operation&gt;
      &lt;wsdl:operation name="getAllPersoonData"&gt;
          &lt;wsdl:input message="ns:getCustomerCredentials2"/&gt;
          &lt;wsdl:output message="ns3:PersoonList"/&gt;
      &lt;/wsdl:operation&gt;
  </code></pre>
  
  <p>This seems to work, except that it now returns a count=0 array in VS10</p>
  
  <p><strong>Another Update</strong></p>
  
  <p>In the comments someone posted a <a href="https://bugs.php.net/bug.php?id=49169" rel="nofollow">link</a> to a bug report with PHP. The second last commenter claimed that he worked around this same issue I have by placing all the message defenitions in other files and included them in this main WSDL document. I tried this but it did not work, nothing changed.</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>So I changed the order of the functions defined in the binding method, and figured out the following: only the first function defined in the binding area works, so in this case only my getAllLessenData works, because I put it above all the others. Does anyone see an error?</p>
  
  <pre><code> &lt;wsdl:binding name="DataBinding" type="tns:DataPort"&gt;
      &lt;soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/&gt;
      &lt;wsdl:operation name="getAllLessenData"&gt;
          &lt;soap:operation soapAction="" style="document"/&gt;
          &lt;wsdl:input&gt;
              &lt;soap:body use="literal"/&gt;
          &lt;/wsdl:input&gt;
          &lt;wsdl:output&gt;
              &lt;soap:body use="literal"/&gt;
          &lt;/wsdl:output&gt;
      &lt;/wsdl:operation&gt;
      &lt;wsdl:operation name="getAllPersoonData"&gt;
          &lt;soap:operation soapAction="" style="document"/&gt;
          &lt;wsdl:input&gt;
              &lt;soap:body use="literal"/&gt;
          &lt;/wsdl:input&gt;
          &lt;wsdl:output&gt;
              &lt;soap:body use="literal"/&gt;
          &lt;/wsdl:output&gt;
      &lt;/wsdl:operation&gt;
      &lt;wsdl:operation name="getAllBetalingData"&gt;
          &lt;soap:operation soapAction="" style="document"/&gt;
          &lt;wsdl:input&gt;
              &lt;soap:body use="literal"/&gt;
          &lt;/wsdl:input&gt;
          &lt;wsdl:output&gt;
              &lt;soap:body use="literal"/&gt;
          &lt;/wsdl:output&gt;
      &lt;/wsdl:operation&gt;
      &lt;wsdl:operation name="getPersoonLessenData"&gt;
          &lt;soap:operation soapAction="" style="document"/&gt;
          &lt;wsdl:input&gt;
              &lt;soap:body use="literal"/&gt;
          &lt;/wsdl:input&gt;
          &lt;wsdl:output&gt;
              &lt;soap:body use="literal"/&gt;
          &lt;/wsdl:output&gt;
      &lt;/wsdl:operation&gt;
      &lt;wsdl:operation name="getPersoonBetalingenData"&gt;
          &lt;soap:operation soapAction="" style="document"/&gt;
          &lt;wsdl:input&gt;
              &lt;soap:body use="literal"/&gt;
          &lt;/wsdl:input&gt;
          &lt;wsdl:output&gt;
              &lt;soap:body use="literal"/&gt;
          &lt;/wsdl:output&gt;
      &lt;/wsdl:operation&gt;
  &lt;/wsdl:binding&gt;
  </code></pre>
  
  <p><strong>end of update</strong></p>
  
  <p>I'm having a little problem with WSLD (again)</p>
  
  <p>my getAllLessenData (and other functions) all return NULL while one function (getAllPersoonData) returns what is expected.</p>
  
  <p>WSDL array defenitions:</p>
  
  <pre><code>&lt;xsi:element name="PersoonArray"&gt;
              &lt;xsi:complexType&gt;
                  &lt;xsi:sequence&gt;
                      &lt;xsi:element name="Persoon" type="tns:Persoon" maxOccurs="unbounded"/&gt;
                  &lt;/xsi:sequence&gt;
              &lt;/xsi:complexType&gt;
          &lt;/xsi:element&gt;
          &lt;xsi:element name="LessenArray"&gt;
              &lt;xsi:complexType&gt;
                  &lt;xsi:sequence&gt;
                      &lt;xsi:element name="Les" type="tns:Les" maxOccurs="unbounded"/&gt;
                  &lt;/xsi:sequence&gt;
              &lt;/xsi:complexType&gt;
          &lt;/xsi:element&gt;
  </code></pre>
  
  <p>WSDL complexType defenitions:</p>
  
  <pre><code>        &lt;xsi:complexType name="Les"&gt;
              &lt;xsi:attribute name="ID" type="xsi:int"/&gt;
              // lots of stuff //
              &lt;xsi:attribute name="Definitief" type="xsi:boolean"/&gt;
          &lt;/xsi:complexType&gt;
          &lt;xsi:complexType name="Persoon"&gt;
              &lt;xsi:attribute name="ID" type="xsi:int"/&gt;
              &lt;// lots of stuff //
              &lt;xsi:attribute name="Laatste_keer_bewerkt" type="xsi:dateTime"/&gt;
          &lt;/xsi:complexType&gt;
  </code></pre>
  
  <p>WSDL message defenitions:</p>
  
  <pre><code>&lt;wsdl:message name="getCustomerID"&gt;
      &lt;wsdl:part name="CustomerID" type="xs:int"/&gt;
  &lt;/wsdl:message&gt;
  &lt;wsdl:message name="PersoonList"&gt;
      &lt;wsdl:part name="PersoonList" element="tns:PersoonArray"/&gt;
  &lt;/wsdl:message&gt;
      &lt;wsdl:message name="LessenList"&gt;
      &lt;wsdl:part name="LessenList" element="tns:LessenArray"/&gt;
  &lt;/wsdl:message&gt;
  </code></pre>
  
  <p>WSDL portType defenition</p>
  
  <pre><code> &lt;wsdl:operation name="getAllPersoonData"&gt;
          &lt;wsdl:input message="tns:getCustomerID"/&gt;
          &lt;wsdl:output message="tns:PersoonList"/&gt;
      &lt;/wsdl:operation&gt;
      &lt;wsdl:operation name="getAllLessenData"&gt;
          &lt;wsdl:input message="tns:getCustomerID"/&gt;
          &lt;wsdl:output message="tns:LessenList"/&gt;
      &lt;/wsdl:operation&gt;
  </code></pre>
  
  <p>WSDL Binding defention</p>
  
  <pre><code>        &lt;soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/&gt;
      &lt;wsdl:operation name="getAllPersoonData"&gt;
          &lt;soap:operation soapAction="http://localhost/weGotcha/servicehandler/servicehandler.php" style="document"/&gt;
          &lt;wsdl:input&gt;
              &lt;soap:body use="literal"/&gt;
          &lt;/wsdl:input&gt;
          &lt;wsdl:output&gt;
              &lt;soap:body use="literal"/&gt;
          &lt;/wsdl:output&gt;
      &lt;/wsdl:operation&gt;
      &lt;wsdl:operation name="getAllLessenData"&gt;
          &lt;soap:operation soapAction="http://localhost/weGotcha/servicehandler/servicehandler.php" style="document"/&gt;
          &lt;wsdl:input&gt;
              &lt;soap:body use="literal"/&gt;
          &lt;/wsdl:input&gt;
          &lt;wsdl:output&gt;
              &lt;soap:body use="literal"/&gt;
          &lt;/wsdl:output&gt;
      &lt;/wsdl:operation&gt;
  </code></pre>
  
  <p>PHP function defenitions:</p>
  
  <pre><code>function getAllPersoonData($customer_ID)
  {
     connectToDB();
  //////////// yes I use mysqli now /////////////
     $sql = "SELECT * FROM personen WHERE Customer_ID='". $customer_ID ."'";
  
     $sql = mysql_query($sql) or die(mysql_error());
     $result = array();
     while($row = mysql_fetch_array($sql))
     {
    $row["Kosten_totaal"] = mysql_fetch_array(mysql_query("SELECT SUM(Kosten) FROM lessen WHERE Persoon_ID='". $row["ID"] ."'"))[0];
      $row["Totaal_betaald"] = mysql_fetch_array(mysql_query("SELECT SUM(Bedrag) FROM betalingen WHERE Persoon_ID='". $row["ID"] ."'"))[0];
      $lkbDatum = strtotime($row["Laatste_keer_bewerkt"]);
    $row["Laatste_keer_bewerkt"] = date("Y-m-d", $lkbDatum) . "T". date("H:i:s", $lkbDatum);
    $result[] = $row;             
  }
  mysql_close();
  
     return $result;
   }
  
  
   function getAllLessenData($customer_ID)
   {
  $sql = "SELECT * FROM lessen WHERE Customer_ID='". $customer_ID ."'";
  //////////// yes I use mysqli now /////////////
  connectToDB();
  
      $sql = mysql_query($sql) or die(mysql_error());
  $result = array();
  while($row = mysql_fetch_array($sql))
  {
    $result[] = $row;
  }
  mysql_close();
  
      return $result;
   }
  
   $server = new SoapServer("wsdl_service.wsdl");
   $server-&gt;AddFunction("getAllPersoonData");
   $server-&gt;AddFunction("getAllBetalingData");
   $server-&gt;AddFunction("getPersoonBetalingData");
   $server-&gt;AddFunction("getAllLessenData");
   $server-&gt;AddFunction("getPersoonLessenData");
   $server-&gt;handle();
  </code></pre>
  
  <p>Test.php</p>
  
  <pre><code>$client = new SoapClient("http://localhost/weGotcha/servicehandler/wsdl_service.wsdl", array("trace" =&gt; 1));
  
  var_dump($client-&gt;__getFunctions());
  
  var_dump($client-&gt;getAllLessenData(1));
  
  var_dump($client-&gt;__getLastRequest());
  var_dump($client-&gt;__getLastResponse());
  </code></pre>
  
  <p>which returns:</p>
  
  <pre><code>array (size=5)
    0 =&gt; string 'PersoonArray getAllPersoonData(int $CustomerID)' (length=47)
    1 =&gt; string 'LessenArray getAllLessenData(int $CustomerID)' (length=45)
    2 =&gt; string 'BetalingenArray getAllBetalingData(int $CustomerID)' (length=51)
    3 =&gt; string 'LessenArray getPersoonLessenData(int $getCustomerID, int $getPersoonID)' (length=71)
    4 =&gt; string 'BetalingenArray getPersoonBetalingenData(int $getCustomerID, int $getPersoonID)' (length=79)
  null
  string '&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"&gt;&lt;SOAP-ENV:Body&gt;&lt;CustomerID&gt;1&lt;/CustomerID&gt;&lt;/SOAP-ENV:Body&gt;&lt;/SOAP-ENV:Envelope&gt;
  ' (length=195)
  string '&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"  xmlns:ns1="http://localhost/weGotcha/servicehandler/wsdl_service.wsdl"&gt;&lt;SOAP-ENV:Body&gt; &lt;ns1:PersoonArray&gt;&lt;ns1:Persoon ID="1" Voornaam="xxxx" Achternaam="xxxx"  Adres="xxxx" Postcode="xxxx" Woonplaats="xxxx"  Email_adres="xxxx" Telefoonnummer="xxxx" Geboortedatum="0001-01-01" CBR_kandidaatnummer="12381233" Rijbewijs="2" Theorie_behaald="false" Theorie_po'... (length=3096)
  </code></pre>
  
  <p>There are rows in my database and calling getAllLessenData(1) directly from my servicehandler.php returns the expected results. however, in my test.php it simply returns NULL and the getLastResponse returns the results from getAllPersoonData(1).</p>
  
  <p>Both function defenitions look the same for me, heck I copy-pasted most of it. I tried changing namespaces etc. google. but it didn't work. Any ideas?</p>
  
  <p>If you need more info please respond.</p>