从现有WSDL创建SOAP服务器返回NULL


Creating SOAP server from existing WSDL returns NULL

我需要从现有的wsdl文件中为使用ocpp协议的系统创建一个中央系统(SOAP服务器)。(开放充电点协议)

我已经成功地在非WSDL模式和WSDL模式下编写了测试SOAP服务器和客户端,但是当我尝试使用现有的WSDL时,我得到的只是一堆错误(这并没有告诉我太多)

WSDL文件可以在这里找到(中央系统chargepoint)。对不起,不能提供更多的链接…)

我已经修正了许多错误,但是无法通过这个。
我猜server.php有一个错误,不返回任何东西,但我不知道为什么或如何使它工作。

为什么服务器不能识别请求或者这里发生了什么?

var_dump (客户端-> __getLastRequestHeaders () );

字符串(201)POST/testi/OCPPServer.php HTTP/1.1主机:127.0.0.1 .php连接:Keep-Alive用户代理:PHP-SOAP/5.6.8 Content-Type:应用程序/soap + xml;charset = utf - 8;action = "/心跳"内容-长度:276 "

var_dump (客户端-> __getLastRequest () );

字符串(276)" 1234 "

var_dump (客户端-> __getLastResponseHeaders () );

var_dump (客户端-> __getLastResponse () );

下面是我得到的代码:

server.php

<?php
ini_set("soap.wsdl_cache_ttl", "0"); 
header("Content-type:text/xml");
# This class handles OCPP central system functions
class OCPPFunctions {
    public function Heartbeat() {
        #$date = date('Y-m-d H:i:s');
        #return array('currentTime' => $date);
        #return $date;      
        #test datetime
        return array('currentTime' => '2010-10-10T10:10:10Z');

  }
    public function BootNotification($params) {
        $result['RegistrationStatus'] = "Accepted";
        $result['currentTime'] = "";
        $result['heartbeatInterval'] = 100000;
        return $result;
    }
}
    $server = new SoapServer("http://127.0.0.1/testi/ocppcp.wsdl", 
        array('trace' => 1));
    $server->setClass('OCPPFunctions'); 
    $server->handle(); 

?>

client.php

<?php 
ini_set("soap.wsdl_cache_ttl", "0"); 
$wsdl_local = "http://127.0.0.1/testi/ocppcs.wsdl";
$client = new SoapClient($wsdl_local,
  array('trace' => 1 ,
     'soap_version' => SOAP_1_2,
     'location' => 'http://127.0.0.1/testi/server.php'));
$header = new SoapHeader('urn://Ocpp/Cs/2012/06/', 'chargeBoxIdentity',    '1234' );
$client->__setSoapHeaders($header);
var_dump($client->__getFunctions());
echo '<br>';
try {
    $result = $client->__soapCall('Heartbeat', array());
    echo $result;
} catch(SoapFault $e) {
    var_dump($e);
}
?>

SoapFault var_dump ($ e) 我是:

object(SoapFault)#3 (9) {["message":protected]=> string(27)"获取http报头错误" ["string":"Exception":private]=> string(0)">["代码":保护]=> int(0)("文件":保护)=>字符串(58)"/Applications/XAMPP/xamppfiles/htdocs/testi/OCPPClient.php" ["line":protected]=> int(21) ["trace":"Exception":private]=> array(2) {[0]=> array(4) {["function"]=> string(11)"__doRequest" ["class"]=> string(10)"SoapClient" ["type"]=> string(2)"->" ["args"]=> array(5) {[0]=> string(276)" 1234 " [1]=> string(37)" http://localhost/test/ocppserver .php" [2]=> string(10)"/心跳"[3]=> int (2) [4] => int(0)}}[1] =>数组(6){("文件")=>字符串(58)"/Applications/XAMPP/xamppfiles/htdocs/testi/OCPPClient.php" ["line"]=> int(21) ["function"]=> string(10)"__soapCall" ["class"]=> string(10)"SoapClient" ["type"]=> string(2)"->" ["args"]=> array(2) {[0]=> string(9)"Heartbeat" [1]=> array(1) {["foo"]=> string(3)"bar"}}}} ["previous":"Exception":private]=> NULL ["faultstring"]=> string(27)"获取http报头错误" ["faultcode"]=> string(4)"HTTP"}

任何帮助或提示将不胜感激!

var_dump(client);

如果它返回NULL,那么它是一个网络问题,如果它返回你的soap调用细节,那么它是一个代码问题。

它最有可能在您的soap选项数组,因为如果我记得正确的话,uri和选项仅在wdsl为空值(NON-WDSL MODE)时使用