1
votes

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!

1

1 Answers

0
votes
var_dump(client);

if it returns NULL than it is a network issue and if it returns your soap call details than it is a code issue.

it is most likely in your soap options array , because if i remember correctly uri and options are only used when the wdsl is a null value (NON-WDSL MODE)