Tag Archives: php online classes
How to install soap in php
Steps : How to install soap in php
Step 1 : Download soap library nusoap-for-php5 from the link :
http://sourceforge.net/projects/nusoap/?source=typ_redirect
Step 2 : unzip the nosoap in new folder “firstweb”.
Step 3 : Now Create two files server.php and client.php.
Step 4 : Inside the server.php Add the following code :
register('getUserData', array('value' => 'xsd:string'), array('return' => 'xsd:string'), 'urn:server', 'urn:server# getUserData');
function getUserData ()
{
$items = array();
$con = mysql_connect('localhost','root','');
mysql_select_db('mydb', $con);
$sql = "SELECT * FROM users";
$query = mysql_query($sql);
while($row = mysql_fetch_array($query)){
$items [] = array(
'id'=>$row['id'],
'name'=>$row['name'],
'email'=>$row['email'],
'profile_image'=>$row['profile_image']
);
}
return $items;
}
/*
You can add more functions here as per the requirement for the database connection make a connection class and include it in header
*/
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server ->service($HTTP_RAW_POST_DATA);
?>
Now you have created the function on server.php file which will fetch data and return the response.
Step 5 : Add the following code in the client.php
call('getUserData'); if($client->fault) { echo "Eroor: Code-".$client ->faultcode.""; } else { $result = $response; } print_r($result); ?>
Not Hit the client.php in url it will return the result.
Note: Client.php file is used for testing and development purpose.
All data which will be returned through the webservice will be in the form of the xml data set.