Couldn't get nusoap to work with database!!

Help
Karl Pablo
2009-04-03
2013-06-06
  • Karl Pablo
    Karl Pablo
    2009-04-03

    I've pinpointed the error but I have no idea how to solve it. NuSoap servers doesn't seem to have an idea on how to query from a mysql database or something.

    Client:

    <?php
    /*
    require_once('lib/nusoap.php');

    $string = '404-587-334-C91';
    $stringArray = array($string);

    $client = new nusoap_client('http://localhost/searchitparts/nusoap/xref_soap_server.php');
    $result = $client->call('getXREF', $stringArray);

    echo $result;*/
    ?>

    Server:

    <?php
    require_once('lib/nusoap.php');
    require_once('mysqli_connect.php');

    $server = new soap_server();
    $server->register('getXREF');

    function getXREF($search_me){
           
        $q = "SELECT COUNT(*) FROM cross_references WHERE LOCATE('".$search_me."', CONCAT(sku,',',list))>0";   
        $r = mysqli_query($dbc, $q) or die("Error in mysqli_query, Q=".$q); //It seems the error is in this line <<<<<<<<<<<<<<
        $row = mysqli_fetch_array($r, MYSQLI_NUM) or die("Error in mysqli_fetch_array");
        return "# in Database: ".$row[0]."";
        mysqli_close($dbc);
       
    // Use the request to (try to) invoke the service
    $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
    $server->service($HTTP_RAW_POST_DATA);

    ?>

     
    • Fred
      Fred
      2009-04-25

      #1.
      I dont' see the getXREF function closing curly brace...

      #2.
      The client script should have the following, instead of "echo"....

      if ($client->fault) {
          echo '<p><b>Fault: ';
          print_r($result);
          echo '</b></p>';
      } else {
          // Check for errors
          $err = $client->getError();
          if ($err) {
              // Display the error
              echo '<p><b>Error: ' . $err . '</b></p>';
          } else {
          // Display the result
          print '<pre>';
          print_r($result);
          print '</pre>';
          }
      }

      #3.
      Your function "getXREF" MUST have input and output arguments when using $server->register(). Please check the documentation examples regarding "hello.php".

      #4.
      If you still cannot manage to overcome the problem, error messages are welcomed here :)
      Nusoap usually hides php errors and warnings so do please consider (#2).

      Tell me if you managed to succeed.