I am trying to make a SoapServer with these 3 files below, everyting works fine, however when I include globalVariables from another folder it causes this error "Uncaught SoapFault exception: [Client] looks like we got no XML document" When it is not included it normaly returns true. The include is required for further development so I need to know how to include correctly.
I've tried to delete the includes and it worked.
First document client side.
<?php
ini_set("default_socket_timeout", 600);
class client
{
public function __construct()
{
$param = array('location' => 'ctecka.eu/SOAP/server.php',
'uri' => 'urn://ctecka.eu/SOAP/server.php',
'trace' => 1);
$this->instance = new SoapClientNG("wsdl.wsdl", array('soap_version' => SOAP_1_2));
}
public function getPacientName($id_array)
{
return $this->instance->__soapCall('getPatientName', $id_array);
}
}
class SoapClientNG extends \SoapClient{
public function __doRequest($req, $location, $action, $version = SOAP_1_2){
$xml = explode("
", parent::__doRequest($req, $location, $action, $version));
$response = preg_replace( '/^(\x00\x00\xFE\xFF|\xFF\xFE\x00\x00|\xFE\xFF|\xFF\xFE|\xEF\xBB\xBF)/', "", $xml[0] );
return $response;
}
}
function strip_bom( $str ) {
return preg_replace( '/^(\x00\x00\xFE\xFF|\xFF\xFE\x00\x00|\xFE\xFF|\xFF\xFE|\xEF\xBB\xBF)/', "", $str );
}
$client = new client;
?>
Server side
<?php
ini_set("default_socket_timeout", 600);
include (.../globalniPromene/login.php);
require_once('../Db.php');
class server
{
private $connection;
public function __construct()
{
$this->connection = (is_null($this->connection)) ? self::connect() : $this->connection;
}
static function connect()
{
$connection = mysqli_connect('81.2.194.30', 'f76655', '76uv6v6');
$db = mysqli_select_db('f76655', $connection);
return $connection;
}
public function getPacientName($id_array)
{
$id = $id_array['ID_pacient'];
$sql= "SELECT jmeno FROM xy1_pacienti WHERE ID_pacient = '. $id. '";
$qry = mysqli_query($sql, $this->connection);
$res = mysqli_fetch_array($qry);
return $res['jmeno'];
}
}
$param = array('uri' => 'ctecka.eu/SOAP/server.php');
$server = new SoapServer("wsdl.wsdl", array('soap_version' => SOAP_1_2));
$server->setClass('server');
$server->handle();
?>
Service
<?php
ini_set("default_socket_timeout", 600);
include './client.php';
$id_array = array('ID_pacient' => '328');
echo $client->getPacientName($id_array);
?>