Linto's Blog

Just another WordPress.com weblog

Example code for SOAP , using nusoap library January 23, 2012

Filed under: SOAP — linodavis @ 4:45 pm

<?php
/**

This is for getting a list of doctors, by giving address

**/
session_start();

// Enable error reporting
// ini_set(“display_errors”,”1″);
//  ini_set(“error_reporting”, E_ALL);

// Pull in the NuSOAP code
require_once(‘nusoap/lib/nusoap.php’);

// Create the client instance
//  $client = new nusoap_client(‘http://dev1.uvjtech.net/gev/API/Doctors.php?wsdl’, true);
$client = new nusoap_client(‘http://my2020i.com/gev/API/Doctors.php?wsdl’, true);

// Check for an error
$err = $client->getError();
if ($err) {
// Display the error
echo ‘<h2>Constructor error</h2><pre>’ . $err . ‘</pre>’;
// At this point, you know the call that follows will fail
}

// Search Doctor…
$error_text = “”;
if(isset($_POST['search']) && $_POST['search'] == “Search”){

$address = strip_tags($_POST['address']);
if($address){
// Call the SOAP method
$doctor_list = $client->call(‘GetDoctorsList’, array(‘address’ => $address)); // echo ‘<pre>’; print_r($doctor_list); exit;
}else{
$error_text = “Invalid Address”;
}
}

//echo ‘<h2>Response</h2><pre>’ . htmlspecialchars($client->response, ENT_QUOTES) . ‘</pre>’;

?>
<html>
<head>
<title>Doctor Search</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>
<script language=”JavaScript” src=”includes/js/ajax.js”></script>
</head>

<body>
<table width=”100%” cellpadding=”1″ cellspacing=”1″ align=”center”  border=”0″>
<tr>
<td colspan=”2″ align=”center” height=”100″> <b>Search Doctor</b></td>
</tr>

<tr>

<td colspan=”2″ width=”80%” valign=”top” align=”center”>
<form name=”frm_search” action=”" method=”post”>
<table>
<tr>
<td  colspan=”2″><?php echo $error_text; ?></td>
</tr>
<tr >
<td >Address</td>
<td >
<input type=”text” name=”address” size=”30″ value=”<?php echo $_POST['address']; ?>” />
<input type=”submit” value=”Search” name=”search” />
</td>
</tr>
<tr>
<td  colspan=”2″></td>
</tr>
</table>
</form>
</td>
</tr>

<?php if($_POST['search']){
?>
<tr>
<td width=”80%” align=”center”>

<table width=”50%” border=”0″ bgcolor=”#333333″ cellspacing=”0″ cellpadding=”0″>
<tr><td><table width=”100%” border=”0″ cellspacing=”1″ cellpadding=”1″>
<?php
if($doctor_list){
?>

<tr><td colspan=”2″ align=”center” bgcolor=”#DDDDDD”><b>Doctors</b></td></tr>

<?php
$i = 1;
foreach($doctor_list as $doctor){
?>
<tr><td width=”5%” align=”center” bgcolor=”#DDDDDD”><?php echo $i; ?></td>
<td bgcolor=”#DDDDDD”><a href=”javascript:void(0);” onClick=”window.open(‘doctor_details.php?id=<?php echo $doctor[user_id]; ?>’,'Doctor Details’,'width=500,height=500′);”><?php echo $doctor['user_fname'].’ ‘.$doctor['user_lname'] ;?></a></td>
</tr>
<?php
$i++;
}

}else{
?>
<tr><td colspan=”2″ align=”center” bgcolor=”#DDDDDD”><b>No Records found</b></td></tr>

<?php

}
?>
</table>

</td>
</tr>
</table>
</td>

<?php }?>

</tr>

<tr>
<td><table width=”30%” border=”0″ cellspacing=”0″ cellpadding=”0″>
<tr><td align=”center” bgcolor=”#DDDDDD” height=”25″><b>Chat logs</b></td></tr>
<tr><td align=”left” ><div id=”chat_log” style=”width:400;height:300;overflow-y:scroll”></div></td></tr>
</table>
</td>
</tr>
</table>

<script type=”text/javascript”>
//setInterval(“ViewMessage()”,3000);

function clock()
{
var d=new Date();
var t=d.toLocaleTimeString();
//document.getElementById(“chat_log”).innerHTML=t;
//document.getElementById(“chat_log”).innerHTML = document.getElementById(“chat_log”).innerHTML+’hai<br />’;
}
</script>

</body>
</html>

Advertisement
 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.