Added Web Service Examples

Signed-off-by: Willy Sudiarto Raharjo <willysr@gmail.com>
This commit is contained in:
Willy Sudiarto Raharjo
2013-03-18 21:47:42 +07:00
parent 23f2f79a7a
commit 3cf3b24385
3 changed files with 286 additions and 0 deletions
+80
View File
@@ -0,0 +1,80 @@
<?php
// Lakukan pemanggilan SOAP apabila ada permintaan berupa form yang disubmit
if ($_SERVER['REQUEST_METHOD'] == "POST")
{
$client = new SoapClient("http://library.ukdw.ac.id/ws/index.php?wsdl");
// Mengambil data sesuai dengan form yang dikirimkan
if (isset($_POST['judul']) && (trim($_POST['judul']) != ""))
{
$judul = $_POST['judul'];
$result = $client->getBukuByJudul("$judul", 0);
}
else if (isset($_POST['pengarang']) && (trim($_POST['pengarang']) != ""))
{
$pengarang = $_POST['pengarang'];
$result = $client->getBukuByPengarang("$pengarang", 0);
}
else if (isset($_POST['penerbit']) && (trim($_POST['penerbit']) != ""))
{
$penerbit = $_POST['penerbit'];
$result = $client->getBukuByPenerbit("$penerbit", 0);
}
// Proses array
foreach($result as $k=>$v)
{
print "
<table>
<tr>
<td align='left'>No: " . ($k+1) . "</td>
</tr>
<tr>
<td align='left'>No. Ref: " . $v->norefb . "</td>
</tr>
<tr>
<td align='left'>Call Number: " . $v->callnumb . "</td>
</tr>
<tr>
<td align='left'>Pengarang " . $v->pengarang . "</td>
</tr>
<tr>
<td>Judul: " . $v->judul . "</td>
</tr>
<tr>
<td align='left'>Penerbit: " . $v->penerbit . "</td>
</tr>
<tr><td><hr/></td></tr>
</table>";
}
}
else // Tidak ada proses submit, berarti tampilkan form
{
?>
<html>
<head>
<title>Contoh Akses Web Service Perpustakaan UKDW Menggunakan SOAP</title>
</head>
<body>
<form action="soap.php" method="post">
Masukkan Judul Buku yang hendak Dicari?
<input id="judul" name="judul" size="50" type="text"/>
<input id="submit" name="submit" type="submit" value="submit" />
</form>
<form action="soap.php" method="post">
Masukkan nama pengarang buku hendak Dicari?
<input id="pengarang" name="pengarang" size="50" type="text"/>
<input id="submit" name="submit" type="submit" value="submit" />
</form>
<form action="soap.php" method="post">
Masukkan nama penerbit buku hendak Dicari?
<input id="pengarang" name="penerbit" size="50" type="text"/>
<input id="submit" name="submit" type="submit" value="submit" />
</form>
</body>
</html>
<?php
}
?>