Archive for the ‘Web Service’ Category

Nusoap Web Service Arrays

Friday, February 1st, 2008

NuSOAP is a group of PHP classes that allow developers to create and consume SOAP web service. Showing no imagination whatsoever, I used this example to present how to return value is array in nusoap web service. (more…)

Nusoap Web Service Arrays (2)

Friday, February 1st, 2008


Previous entire review hello.php .The client changes only in that it passes a parameter that is an array of names, rather than a single scalar name. (more…)

Definition of Web Service

Thursday, January 31st, 2008


If you asked ten people to define the term Web Service , you are likely to get ten different answers. This term has no single definition. Even the standards authorities cannot agree on what this term means. Before presenting you with what I consider to be a Web sevice, let’s first examine some definitions you may encounter. (more…)

Example PHP Web Service Return Selection Result (2)

Wednesday, January 30th, 2008


The first file I describe in service.php is a service that created in this article describe how to create a client to call service.php . Web service you can call service you must know endpoint of service argument name input parameter not enough you must know the type of input parameter. in service.php that I describe before have one method is “search” input parameter is “keyword”

require_once(’lib\nusoap.php’);
$client = new soapclient(’http://203.157.178.8/hciss/hcissservice/helloservice.php’);
$result = $client->call(’hello’, array(’name’ => ‘Sam’));
printf($result);
?>

Example PHP Web Service Return Selection Result (1)

Wednesday, January 30th, 2008

It well time that I can create web service. I have my database and want to select data return result. How I do ?
I create 2 file service.php and callservice.php in service.php contain 2 function .
First function query data from database

function searchPatient($word)
{
$hostname_hciss = “localhost”;
$database_hciss = “hciss”;
$username_hciss = “root”;
$password_hciss = “”;
$hciss = mysql_pconnect($hostname_hciss, $username_hciss, $password_hciss) or trigger_error(mysql_error(),E_USER_ERROR);

if (!$hciss)
{
die(’Could not connect: ‘ . mysql_error());
}

mysql_select_db($database_hciss, $hciss);

$sql = “SELECT P_CODE, id_Card, fNAME, lNAME FROM person WHERE P_CODE LIKE ‘%”.$word.”%’ OR id_Card LIKE ‘%”.$word.”%’ OR fNAME LIKE ‘%”.$word.”%’ OR lNAME LIKE ‘%”.$word.”%’”;

$result = mysql_query($sql, $hciss) or die(mysql_error());

mysql_close($hciss);

return $result;
}

Second Function call searchPatient() and create table to return

function search($keyword)
{
$resultSearch = searchPatient($keyword);
$codeResult = "

P CODE ID FIRST NAME LAST NAME
“.$row[’P_CODE’].” “.$row[’id_Card’].” “.$row[’fNAME’].” “.$row[’lNAME’].”

“;
//return result in datarow
return $codeResult;
}

This complete file service.php

require_once(’lib\nusoap.php’);
$server = new soap_server;
$server->register(’search’, // method name
array(’keyword’ => ‘xsd:string’), // input parameters
array(’return’ => ‘xsd:string’), // output parameters
‘urn:hcissSearch’, // namespace
‘urn:hellowsdl#hcissSearch’, // soapaction
‘rpc’, // style
‘encoded’, // use
‘Return table of search result’); // documentation

function searchPatient($word)
{
$hostname_hciss = “localhost”;
$database_hciss = “hciss”;
$username_hciss = “root”;
$password_hciss = “”;
$hciss = mysql_pconnect($hostname_hciss, $username_hciss, $password_hciss) or trigger_error(mysql_error(),E_USER_ERROR);

if (!$hciss)
{
die(’Could not connect: ‘ . mysql_error());
}

mysql_select_db($database_hciss, $hciss);

$sql = “SELECT P_CODE, id_Card, fNAME, lNAME FROM person WHERE P_CODE LIKE ‘%”.$word.”%’ OR id_Card LIKE ‘%”.$word.”%’ OR fNAME LIKE ‘%”.$word.”%’ OR lNAME LIKE ‘%”.$word.”%’”;

$result = mysql_query($sql, $hciss) or die(mysql_error());

mysql_close($hciss);

return $result;
}

function search($keyword)
{
$resultSearch = searchPatient($keyword);
$codeResult = ”

P CODE ID FIRST NAME LAST NAME
“.$row[’P_CODE’].” “.$row[’id_Card’].” “.$row[’fNAME’].” “.$row[’lNAME’].”

“;
//return result in datarow
return $codeResult;
}

$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : ”;
$server->service($HTTP_RAW_POST_DATA);
?>

net to callservice.php