2017-06-21 102 views
0

我只用WEB API的工作,直到如今,我無法弄清楚如何準確SOAP工作。 PHP官方網站缺乏詳細的信息,少數例子並沒有幫助我很多。我相信,如果我得到DoLogin函數工作,我可以處理所有其餘的事情,但我錯過了一些小事,不知道究竟是什麼。這裏的代碼,我到現在爲止:從這個代碼PHP SOAP API設置/登錄

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); 

反應是以下錯誤:

Server was unable to process request. ---> A service call threw a security fault exception - Security.Fault: SessionIDNotFound ---> Security.Fault: SessionIDNotFound 

這裏是爲DoLogin功能發佈的接口文檔的鏈接:https://onlineavl2api-us.navmanwireless.com/onlineavl/api/V1.9/service.asmx?op=DoLogin

回答

0

問題在我的語法中:

更改

$UserInfo = array(
... 
'SessionID' => null, 
... 
)); 

$UserInfo = array(
... 
'Session' => array('SessionId' => ''), 
... 
)); 
+0

嗨,我在處理同樣的服務提供商和我瘋狂。它不斷尖叫我的'無法識別的指導格式'。你知道他們需要什麼樣的特殊格式嗎?作爲一個測試,我得到了'A8558E7E-F5A6-4F83-BD39-F1567EA56457',我使用了一些網絡服務驗證器,他們說這看起來沒問題。你有沒有設法將你的應用程序連接到這個接口? – Vilius