Hi guys!.
I'm having an issue with my PHP web service. I'm trying to get some data from Oracle database using nuSoap. First of all, let me show my ws.php and client.php files.
websrv.php
<?php
$conn = oci_connect('user','password','database');
if (!$conn) {
$e = oci_error();
trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}
require_once ('lib/nusoap.php');
$server = new nusoap_server;
$server->register('getCustumer');
function getCustumer($idCustumer) {
$result = oci_parse($conn,'select nm_custumer from custumer where id_custumer >=',$idCustumer);
oci_execute($result);
return $result;
}
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ?
$HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);
?>
client.php
<?php
require_once ('lib/nusoap.php');
$client = new nusoap_client('http://www.webservice.localhost/websrv.php',false);
$param = array('idCustumer'=>'1');
$result = $client->call('getCustumer',$param);
echo "<table border='1'>\n";
while ($row = oci_fetch_array($result, OCI_ASSOC+OCI_RETURN_NULLS)) {
echo "<tr>\n";
foreach ($row as $item) {
echo " <td>" . ($item !== null ? htmlentities($item, ENT_QUOTES) : " ") . "</td>\n";
}
echo "</tr>\n";
}
echo "</table>\n";
?>
Well, these are my files. When I run client.php, it gives me the following error:
( ! ) Warning: ocifetch() expects parameter 1 to be resource, boolean given in C:\wamp\www\WS\client.php on line 31
It seems to be Client.php is not getting into getCustumer function. I really don't know why it gives this error.
In the other hand, If a put both codes (client.php and websrv.php) together, it works. Take a look at the code below.
together.php
<?php
$conn = oci_connect('user','password','database');
if (!$conn) {
$e = oci_error();
trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}
$result = oci_parse($conn, 'select nm_custumer from custumer');
oci_execute($result);
echo "<table border='1'>\n";
while ($row = oci_fetch_array($result, OCI_ASSOC+OCI_RETURN_NULLS)) {
echo "<tr>\n";
foreach ($row as $item) {
echo " <td>" . ($item !== null ? htmlentities($item, ENT_QUOTES) : " ") . "</td>\n";
}
echo "</tr>\n";
}
echo "</table>\n";
?>
I'd appreciate if someone could help me.
If more information is needed, please ask me.
Tks
Aclima
MOD EDIT: When posting PHP code, please use the board's [noparse]
..
[/noparse] bbcode tags as they make your code much easier to read and analyze.