Search code examples
phpweb-servicesnusoap

how to use webservice using nusoap library php


i have try to use the webservice from some site, i use nusoap library and my php code like this

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

   $client = new SoapClient("http://simlitabmas.dikti.go.id/ws_pimnas/ws.svc?wsdl");

  $err = $client->getError();
  if ($err) {
      echo '<h2>errorr BOSSSS </h2><pre>' . $err . '</pre>';
  }

  $param = "examplekeyword";
  $param2 = "001029";
  $result = $client->call('get_peserta',array("keyword"=>"$param","kode_perguruan_tinggi"=>"$param2"));


if (!empty($result)) {

echo "<table border=1>";
echo "<tr bgcolor='#cccccc'>";
echo "<th>Name</th>";
echo "<th>Nomor Mahasiswa</th>";

echo "</tr>";
foreach ($result as $item) {
    echo "<tr>";
    echo "<td>".$item['nama']."</td>";
    echo "<td>".$item['nomor_mahasiswa']."</td>";
    echo "</tr>";
}
echo "</table>";

}
 ?>

The function get_peserta has two parameter to input. when i test my php code i got blank page. Any help?


Solution

  • Using the WSDL from http://simlitabmas.dikti.go.id/ws_pimnas/ws.svc?wsdl, you could generate the corresponding package from wsdltophp.com in order to be sure on how to structure your request in PHP as every element will be a PHP object with setters/getters. Let me know if you need any additional help,