duanlisha2335 2019-07-28 22:11
浏览 117

看起来没有XML文件

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);

?>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 #MATLAB仿真#车辆换道路径规划
    • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
    • ¥15 数据可视化Python
    • ¥15 要给毕业设计添加扫码登录的功能!!有偿
    • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
    • ¥15 微信公众号自制会员卡没有收款渠道啊
    • ¥100 Jenkins自动化部署—悬赏100元
    • ¥15 关于#python#的问题:求帮写python代码
    • ¥20 MATLAB画图图形出现上下震荡的线条
    • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘