Professional Documents
Culture Documents
Laporan Praktikum Cs
Laporan Praktikum Cs
Laporan Praktikum Cs
NIM NAMA
: :
Paraf Dosen
Tanggal Praktek :
1. Menampilkan harga pada database book, tabel buku a. Web Server, dgn nama Perpustakaan1.php <?php function getBooksList() { include "koneksi/koneksi.php"; $result=mysql_query("select * from buku"); $index=0; while($data=mysql_fetch_array($result)) { $books[$index]=array( "id"=>$data['id'], "judul"=>$data['judul'], "pengarang"=>$data['pengarang'], "penerbit"=>$data['penerbit'], "harga"=>$data['harga'] ); $index++; }
1
mysql_close(); return $books; } require("lib/nusoap.php"); $server=new soap_server(); $server->configureWSDL("Books","urn:BooksService"); $server->wsdl->addComplexType( "book", "complexType", "struct", "all", "", array( "id"=>array("name"=>"id","type"=>"xsd:string"), "judul"=>array("name"=>"judul","type"=>"xsd:string"), "pengarang"=>array("name"=>"pengarang","type"=>"xsd:string "), "penerbit"=>array("name"=>"penerbit","type"=>"xsd:string"), "harga"=>array("name"=>"harga","type"=>"xsd:long") ) ); $server->wsdl->addComplexType( "booksArray", "complexType", "array", "", "SOAP-ENC:Array",
2
array(), array( "ref"=>"SOAPENC: arrayType","wsdl:arrayType"=>"tns:book[]" ), "tns:book" ); $server->register( "getBooksList", array(), array("return"=>"tns:booksArray"), "urn:BooksService", "urn:BooksService#getBooksList" ); $HTTP_RAW_POST_DATA=isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : ''; $server->service($HTTP_RAW_POST_DATA); ?>
c. Web Client , cari_buku.php <?php require("lib/nusoap.php"); ?> <html> <head> <title>Client Perpustakaan</title> </head> <body> <form action="caril_buku.php" method="post"> Judul Buku : <input type="text" name="txtjudul"> <input type="submit" name="submit" value="Cari!"> </form> <?php $url="http://localhost/kasirun/perpustakaan1.php"; if($_POST['submit']) { $client=new soapclient($url); $result=$client ->call("getBookList",array("bookJudul"=>$_POST['txtjudul'])); $err=$client->getError(); if($err) { echo "<p><b>ERROR!".$client ->getError()."</b></p>"; } else
4
{ if($result!=null) { print "<TABLE BORDER=1>"; print "<TR bgcolor=lightblue> <TH>ID <TH>Judul <TH>Pengarang<TH>Penerbit<TH>Harga</TR>"; //menampilkan record do{ print "<TR>"; print "<TD> $row->ID<TD>"; print "<TD> <a href=javascript:void(0) onClick=keParent($row->id)>$row>judul</a></TD>"; print "<TD> $row->Penerbit<TD>"; print "<TD> $row->Pengarang<TD>"; print "<TD> $row->Harga<TD>"; print "</TR>"; }while ($row=mysql_fetch_object($rs)); print "</TABLE>"; } else { echo "<b>Kode buku tidak terdaftar!</b>"; } echo "<hr>"."SOAP Request"; echo "<pre>".htmlentities($client >request)."</pre>"; echo "SOAP Response"; echo "<pre>".htmlentities($client >response)."</pre>"; } } ?>
5
</body> </html>