0

Ive been trying for the last few hours to work out this, but for the life of me cant get it right -

http://publicapi.ekmpowershop19.com/v1.1/publicapi.asmx?wsdl

Im trying to use the "GetOrders" function in the above SOAP request, i have been reading tutorial after tutorial but keep getting the following error -

object(stdClass)#2 (1) { ["GetOrdersResult"]=> object(stdClass)#3 (5) { ["Status"]=> string(7) "Failure" ["Errors"]=> object(stdClass)#4 (1) { ["string"]=> string(53) "Object reference not set to an instance of an object." } ["Date"]=> string(33) "2017-04-24T13:08:03.1200825+01:00" ["TotalOrders"]=> int(0) ["TotalCost"]=> NULL } }

The PHP code i am using is -

<?php $trace = true;
$exceptions = true;
$test = new 
SoapClient('http://publicapi.ekmpowershop19.com/v1.1/publicapi.asmx?wsdl', 
array('trace' => $trace, 'exceptions' => $exceptions));
$xml_array['APIKey'] = REMOVED;
$getorders = $test->GetOrders($xml_array);
var_dump($getorders);
?>

EDIT - Also just tried the below codes to the same effect -

<?php
$trace = true;
$exceptions = true;
$client = new SoapClient("http://publicapi.ekmpowershop19.com/v1.1/publicapi.asmx?wsdl",
array(
  "trace"      => 1,        // enable trace to view what is happening
  "exceptions" => 0,        // disable exceptions
  "cache_wsdl" => 0)        // disable any caching on the wsdl, encase you alter the wsdl server
);
print_r( $client->GetOrders(array("APIKey" => "REMOVED")));
echo "<p>Request :".htmlspecialchars($client->__getLastRequest()) ."</p>";
echo "<p>Response:".htmlspecialchars($client->__getLastResponse())."</p>";
?>
  • __getFunctions()); ?> – Shafiqul Islam Apr 24 '17 at 12:17
  • Not sure how you mean @ShafiqulIslam - I have checked the get functions and GetOrders is there. – Matty Hadfield Apr 24 '17 at 12:24
  • ok which parameter need to use with type and which your getorders function parameter? – Shafiqul Islam Apr 24 '17 at 12:31
  • http://php.net/manual/en/soapclient.getfunctions.php – Shafiqul Islam Apr 24 '17 at 12:33
  • http://stackoverflow.com/questions/11593623/how-to-make-a-php-soap-call-using-the-soapclient-class – Shafiqul Islam Apr 24 '17 at 12:33
  • Your GetOrders method takes more parameters than APIKey, try something like this: $params = array( "APIKey" => "REMOVED", "SearchText" => "", "CustomerID" => "", "Status" => "", "FromDate" => "", "ToDate" => "", "ItemsPerPage" => "", "PageNumber" => 1, "Fields" => "", "OrderBy" => "", ); – mdmg Apr 24 '17 at 12:36
  • @mdmg only the APIKey is required, the rest are optional, do they need to be specified even if not used ? EDIT - Just tried your code - Still no luck – Matty Hadfield Apr 24 '17 at 12:58
  • @MattyHadfield Didnt know about that. Now that I see the WS in detail, the GetOrders method takes GetOrdersRequest object as parameter, and the GetOrdersRequest is composed of APIKey and the others properties. If I'm not wrong you should try sending the parameters as this: $GetOrdersRequest = new stdClass(); $GetOrdersRequest->APIKey = "REMOVED"; $params = array( "GetOrdersRequest" => $GetOrdersRequest, ); – mdmg Apr 24 '17 at 13:15
  • Forgive me @mdmg, this is what i currently have, assuming this is how you meant - '$GetOrdersRequest = new stdClass(); $GetOrdersRequest->APIKey = "REMOVED"; $params = array( "GetOrdersRequest" => $GetOrdersRequest, ); $client = new SoapClient("http://publicapi.ekmpowershop19.com/v1.1/publicapi.asmx?wsdl", array( "trace" => 1, "exceptions" => 0, "cache_wsdl" => 0) );' – Matty Hadfield Apr 24 '17 at 13:49
  • @MattyHadfield yes, try sending $params as parameter now: $client->GetOrders($params); and see the result. – mdmg Apr 24 '17 at 14:06
  • @mdmg still getting the same result. – Matty Hadfield Apr 25 '17 at 08:44

0 Answers0