|
Metode dan Algoritma | Web Service Client PHP NUSOAP Mengakses Web Service C#.NET . Anda bisa melakukan konsultasi tentang Web Service Client PHP NUSOAP Mengakses Web Service C#.NET melalui form di samping kanan !!!
Web Service Client - PHP Mengakses (Consume) Web Service C#.NET
Web Service Client ini akan mengkonsumsi Web Service C#.NET seperti yang diterangkan pada halaman Web Service C#.NET
Copy library NUSOAP ke dalam direktori lib
Buat file webservice wsclientasp.php, tuliskan kode program berikut :
<html>
<head></head>
<body>
<table width="700" border="1" cellspacing="2" cellpadding="3">
<tr>
<td>ID</td>
<td>Name</td>
<td>Description</td>
<td>Date</td>
<td>Price</td>
<td> </td>
</tr>
<?php
require_once('lib/nusoap.php');
$client = new soapclient('http://localhost:1495/ws/Service.asmx?wsdl', true);
$params = '';
$result = $client->call("getTb", $params);
//print_r($result['getTbResult']['diffgram']['NewDataSet']['admin']); //[0]['Nama']);
for ($i=0;$i<count($result['getTbResult']['diffgram']['NewDataSet']['tb']);$i++)
{
?>
<tr>
<td><?php echo $result['getTbResult']['diffgram']['NewDataSet']['tb'][$i]['id']; ?> </td>
<td><?php echo $result['getTbResult']['diffgram']['NewDataSet']['tb'][$i]['nm']; ?> </td>
<td><?php echo $result['getTbResult']['diffgram']['NewDataSet']['tb'][$i]['dsc']; ?> </td>
<td><?php echo $result['getTbResult']['diffgram']['NewDataSet']['tb'][$i]['dt']; ?> </td>
<td><?php echo $result['getTbResult']['diffgram']['NewDataSet']['tb'][$i]['prc']; ?> </td>
<td><a href="wsclientaspedit.php?id=<?php echo $result['getTbResult']['diffgram']['NewDataSet']['tb'][$i]['id']; ?>">Edit</a> <a href="wsclientaspdelete.php?id=<?php echo $result['getTbResult']['diffgram']['NewDataSet']['tb'][$i]['id']; ?>">Del</a> </td>
</tr>
<?php
}
?>
</table>
<br />
<a href="wsclientaspadd.php">Add</a>
</body>
</html>
Buat file webservice wsclientaspadd.php, tuliskan kode program berikut :
<?php
if ($_POST['button'] == 'Save')
{
require('lib/nusoap.php');
$client = new soapclient('http://localhost:1495/ws/Service.asmx?wsdl', true);
$result=$client->call("insertTb",
array("id"=>$_POST['id'],"nm"=>$_POST['nm'],"dsc"=>$_POST['dsc'],"dt"=>$_POST['dt'],"prc"=>$_POST['prc']));
$err=$client->getError();
if($err){
echo "error";
}
header("location:wsclientasp.php");
}
?>
<html>
<head></head>
<body>
<form id="form1" name="form1" method="post" action="">
<table width="300" border="1" cellspacing="2" cellpadding="3">
<tr>
<td>ID</td>
<td><label>
<input name="id" type="text" id="id" />
</label></td>
</tr>
<tr>
<td>Name</td>
<td><label>
<input name="nm" type="text" id="nm" />
</label></td>
</tr>
<tr>
<td>Description</td>
<td><label>
<input name="dsc" type="text" id="dsc" />
</label></td>
</tr>
<tr>
<td>Date</td>
<td><label>
<input name="dt" type="text" id="dt" />
</label></td>
</tr>
<tr>
<td>Price</td>
<td><label>
<input name="prc" type="text" id="prc" />
</label></td>
</tr>
<tr>
<td> </td>
<td><label>
<input name="button" type="submit" id="button" value="Save" />
</label></td>
</tr>
</table>
</form>
</body>
</html>
Buat file webservice wsclientaspedit.php, tuliskan kode program berikut :
<?php
if ($_POST['button'] == 'Save')
{
require('lib/nusoap.php');
$client = new soapclient('http://localhost:1495/ws/Service.asmx?wsdl', true);
$result=$client->call("updateTb",
array("id"=>$_POST['id'],"nm"=>$_POST['nm'],"dsc"=>$_POST['dsc'],"dt"=>$_POST['dt'],"prc"=>$_POST['prc']));
$err=$client->getError();
if($err){
echo "error";
}
header("location:wsclientasp.php");
}
?>
<html>
<head></head>
<body>
<?php
require_once('lib/nusoap.php');
$client = new soapclient('http://localhost:1495/ws/Service.asmx?wsdl', true);
$params = '';
$result = $client->call("getTb", $params);
//print_r($result['getAdminResult']['diffgram']['NewDataSet']['admin']); //[0]['Nama']);
if($result!=null){
for ($i=0;$i<count($result['getTbResult']['diffgram']['NewDataSet']['tb']);$i++){
if ($result['getTbResult']['diffgram']['NewDataSet']['tb'][$i]['id'] == $_GET['id'])
{
$id = $result['getTbResult']['diffgram']['NewDataSet']['tb'][$i]['id'];
$nm = $result['getTbResult']['diffgram']['NewDataSet']['tb'][$i]['nm'];
$dsc = $result['getTbResult']['diffgram']['NewDataSet']['tb'][$i]['dsc'];
$dt = $result['getTbResult']['diffgram']['NewDataSet']['tb'][$i]['dt'];
$prc = $result['getTbResult']['diffgram']['NewDataSet']['tb'][$i]['prc'];
}
}
}
?>
<form id="form1" name="form1" method="post" action="">
<table width="300" border="1" cellspacing="2" cellpadding="3">
<tr>
<td>ID</td>
<td><label>
<input name="id" type="text" id="id" value="<?php echo $id; ?>" readonly />
</label></td>
</tr>
<tr>
<td>Name</td>
<td><label>
<input name="nm" type="text" id="nm" value="<?php echo $nm; ?>" />
</label></td>
</tr>
<tr>
<td>Description</td>
<td><label>
<input name="dsc" type="text" id="dsc" value="<?php echo $dsc; ?>" />
</label></td>
</tr>
<tr>
<td>Date</td>
<td><label>
<input name="dt" type="text" id="dt" value="<?php echo $dt; ?>" />
</label></td>
</tr>
<tr>
<td>Price</td>
<td><label>
<input name="prc" type="text" id="prc" value="<?php echo $prc; ?>" />
</label></td>
</tr>
<tr>
<td> </td>
<td><label>
<input name="button" type="submit" id="button" value="Save" />
</label></td>
</tr>
</table>
</form>
</body>
</html>
Buat file webservice wsclientaspdelete.php, tuliskan kode program berikut :
<?php
require_once('lib/nusoap.php');
$client = new soapclient('http://localhost:1495/ws/Service.asmx?wsdl', true);
$result=$client->call("deleteTb",
array("id"=>$_GET['id']));
$err=$client->getError();
if($err){
echo "error";
}
header("location:wsclientasp.php");
?>
Hasilnya dapat dilihat pada url : localhost/wsclient/wsclientasp.php

Related Post :

Judul: Web Service Client PHP NUSOAP Mengakses Web Service C#.NET
Rating: 100% based on 99998 ratings. 5 user reviews.
Ditulis Oleh hank2
Rating: 100% based on 99998 ratings. 5 user reviews.
Ditulis Oleh hank2
Anda sedang membaca artikel tentang
Web Service Client PHP NUSOAP Mengakses Web Service C#.NET, Semoga artikel tentang Web Service Client PHP NUSOAP Mengakses Web Service C#.NET ini sangat bermanfaat bagi teman-teman semua, jangan lupa untuk mengunjungi lagi melalui link
Web Service Client PHP NUSOAP Mengakses Web Service C#.NET.
{ 0 komentar... Views All / Send Comment! }
Posting Komentar