Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/240.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP SOAP API设置/登录_Php_Web Services_Api_Soap - Fatal编程技术网

PHP SOAP API设置/登录

PHP SOAP API设置/登录,php,web-services,api,soap,Php,Web Services,Api,Soap,到目前为止,我只使用过WEB API,不知道SOAP到底是如何工作的。PHP官方网站缺乏详细的信息,而且仅有的几个例子对我帮助不大。我相信如果我使用了DoLogin函数,我可以处理所有其他的事情,但是我遗漏了一些小的东西,并且无法弄清楚到底是什么。以下是我目前掌握的代码: ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache date_default_timezone_set('America/Denver'); $o

到目前为止,我只使用过WEB API,不知道SOAP到底是如何工作的。PHP官方网站缺乏详细的信息,而且仅有的几个例子对我帮助不大。我相信如果我使用了DoLogin函数,我可以处理所有其他的事情,但是我遗漏了一些小的东西,并且无法弄清楚到底是什么。以下是我目前掌握的代码:

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函数:

问题在我的语法中:

改变

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


嗨,我和同一家服务提供商打交道,这让我发疯。它不断尖叫我的
无法识别的Guid格式
。你知道他们需要什么样的特殊格式吗?作为测试,我得到了
A8558E7E-F5A6-4F83-BD39-F1567EA56457
,我使用了一些web服务验证程序,他们说这似乎是可以的。你最终成功地将你的应用程序连接到这个界面了吗?@Vilius你解决过GUID格式的问题吗?我也犯了同样的错误!您能和我分享一下您的GUID函数吗?我在尝试使用同一服务时遇到一个错误“XML文档(221)中有一个错误。-->无法识别的GUID格式”
$UserInfo = array(
...
'Session' => array('SessionId' => ''),
...
));