doulian7305 2015-05-28 09:09
浏览 104

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

I need to create a central system (a SOAP server) from existing WSDL-files for a system using OCPP-protocol.(Open Charge Point Protocol)

I've written test SOAP servers and clients in non-wsdl-mode and wsdl-mode succesfully, but when I try to use existing WSDL all I get is a load of errors (which don't tell me much)

WSDL files can be found here (central system and chargepoint. Sorry, can't post more links..)

I've fixed a number of errors already, but can't get past this one.
I guess server.php has an error and doesn't return anything, but I have no idea why or how to make it work.

Why doesn't server recognize the request or what is happening here?

var_dump($client->__getLastRequestHeaders());

string(201) "POST /testi/OCPPServer.php HTTP/1.1 Host: 127.0.0.1 Connection: Keep-Alive User-Agent: PHP-SOAP/5.6.8 Content-Type: application/soap+xml; charset=utf-8; action="/Heartbeat" Content-Length: 276 "

var_dump($client->__getLastRequest());

string(276) " 1234 "

var_dump($client->__getLastResponseHeaders());

NULL

var_dump($client->__getLastResponse());

NULL

Here is the code I've got:

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) I get is:

object(SoapFault)#3 (9) { ["message":protected]=> string(27) "Error Fetching >http headers" ["string":"Exception":private]=> string(0) "" >["code":protected]=> int(0) ["file":protected]=> string(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 /testi/OCPPServer.php" [2]=> string(10) "/Heartbeat" [3]=> int(2) [4]=> int(0) } } [1]=> array(6) { ["file"]=> string(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) "Error Fetching http headers" ["faultcode"]=> string(4) "HTTP" }

Any help or tips would be appreciated!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 关于#硬件工程#的问题,请各位专家解答!
    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配
    • ¥15 Power query添加列问题
    • ¥50 Kubernetes&Fission&Eleasticsearch
    • ¥15 報錯:Person is not mapped,如何解決?
    • ¥15 c++头文件不能识别CDialog
    • ¥15 Excel发现不可读取的内容