I'm coding a SOAP WebService in PHP and I encounter an issue.
This service is running on a Linux server. I have a function to connect to an Oracle database and another one to connect to a local Memcached server.
So, when I call my Oracle connections's function, SOAP returns :
Uncaught SoapFault exception: [SOAP-ENV:Server] Call to undefined function oci_connect()
But if I create a simple php file with the same Oracle function it's work fine (without SOAP)
I created a simple server/client php files juste for testing and I encounter the same issue, here's my code :
Server :
<?php
class Serveur{
function helloWorld()
{
return "Hello World";
}
function connexionOracle()
{
$conn = oci_connect('XXXXX', 'XXXX', 'XXXXX');
if($conn == false)
{
return "Error";
}
else
{
return "OK";
}
}
}
$serversoap = new SoapServer(null, array('uri' => "http://localhost/test/"));
$serversoap->setClass("Serveur");
$serversoap->handle();
?>
Client :
<?php
error_reporting(E_ALL | E_STRICT);
$client = new SoapClient(null, array('location' => "http://localhost/test/serveur.php",'uri'=> "http://localhost/test/"));
print_r($client->helloWorld());
echo "</br>";
print_r($client->connexionOracle());
?>
This code returns :
Call to undefined function oci_connect()
But if I use a simple file like this one, everything is working :
$conn = connexionOracle2();
var_dump($conn);
function connexionOracle2()
{
$db = "(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(Host = XXXXX)(Port = XXXX)) ) (CONNECT_DATA = (SID = XXXXXX) ) )";
return oci_connect('cartetest', 'evol', $db) or Die('Connexion Oracle impossible');
}
I don't encounter this issue on my local windows machine
This is the solution that worked for me :
setsebool -P httpd_can_network_connect 1
You can also disabled SELinux like this in the configuration file :
SELINUX=disabled
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.