I've only worked with WEB APIs until now and i can't figure out how does SOAP exactly work. PHP official website lacks detailed information and the few examples didn't help me a lot. I believe that if i get the DoLogin function to work i can handle all the rest, but i'm missing something small and can't figure out what exactly. Here's the code i have until now:
ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache
date_default_timezone_set('America/Denver');
$output = array();
$UserName = 'myusername';
$Password = 'mypassword';
$WSDL = 'https://onlineavl2api-us.navmanwireless.com/onlineavl/api/V1.9/service.asmx?WSDL';
$URL = 'https://onlineavl2api-us.navmanwireless.com/onlineavl/api/V1.9/service.asmx';
$client = new SoapClient($WSDL, array('trace' => 1, 'encoding' => 'UTF-8'));
$client->__setLocation($URL);
$GUID = getGUID(); // I have a separate function for creating GUID with PHP i can post if needed
$UserInfo = array(
'request' => array(
'SessionID' => null,
'UserCredential' => array(
'UserName' => $UserName,
'Password' => $Password,
'ApplicationID' => $GUID,
'ClientID' => $GUID,
'ClientVersion' => '1.2'
),
'IPAddress' => $_SERVER['SERVER_ADDR'],
'ClockVerificationUtc' => time()
));
try{
$SessionID = $client->DoLogin($UserInfo);
$AllFunctions = $client->__getFunctions();
$GetTypes = $client->__getTypes();
$LastRequest = $client->__getLastRequest();
$LastResponse = $client->__getLastResponse();
// $SessionID = $client->DoLogin($UserInfo);
}
catch(Exception $e) {
$output['errors'] = $e->getMessage();
}
$output['Types'] = $GetTypes;
$output['Functions'] = $AllFunctions;
$output['result'] = $result;
$output['LastRequest'] = $LastRequest;
$output['LastResponse'] = $LastResponse;
$output['SessionInfo'] = $SessionInfo;
print json_encode($output);
Response from this code is the following error:
Server was unable to process request. ---> A service call threw a security fault exception - Security.Fault: SessionIDNotFound ---> Security.Fault: SessionIDNotFound
Here's a link for the DoLogin function published interface documentation: https://onlineavl2api-us.navmanwireless.com/onlineavl/api/V1.9/service.asmx?op=DoLogin
Problem is in my syntax:
Changed
$UserInfo = array(
...
'SessionID' => null,
...
));
to
$UserInfo = array(
...
'Session' => array('SessionId' => ''),
...
));