我正在尝试连接到需要 Windows 身份验证的 Web 服务。我正在用 PHP 编写代码并尝试调用方法,MS dynamics 365 wsdl
但我得到的只是Forbidden
和608 error code: There is insufficient account information to log you on.
我已经尝试过NTLMSoapClient
和NuSoap
类,但是当它不抛出Forbidden
消息时,它给了我空对象的 NULL 值,最终仍然没有从方法中得到响应。
我的代码与此类似
<?php
$login = "[email protected]";
$password = "password";
$url = "https://domainname.sandbox.ax.dynamics.com/pathto/soap/service/someservice?wsdl";
$arrayOpt = array(
"soap_version" => SOAP_1_1,
"cache_wsdl" =>WSDL_CACHE_NONE,
"exceptions" =>false,
"trace" =>true,
'authentication'=> SOAP_AUTHENTICATION_BASIC,
'login' =>$login,
'password' =>$password
);
$client = new SoapClient($url, $arrayOpt);
$param = array('someParam' => "value");
print_r($client->__getFunctions()); // i get the full functions from the wsdl
$result = $client->getInfo($param);
var_dump($result); // i get a:Forbidden [Message]=>string(55) "There is insufficient account information to log you on"
?>
即使我使用SOAPUI
我也得到相同的结果
<s:Fault>
<faultcode xmlns:a="http://schemas.microsoft.com/2009/WebFault">a:Forbidden</faultcode>
<faultstring xml:lang="en-US">Forbidden</faultstring>
<detail>
<Win32Exception xmlns="http://schemas.datacontract.org/2004/07/System.ComponentModel" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:x="http://www.w3.org/2001/XMLSchema">
<NativeErrorCode i:type="x:int" xmlns="">608</NativeErrorCode>
<ClassName i:type="x:string" xmlns="">System.ComponentModel.Win32Exception</ClassName>
<Message i:type="x:string" xmlns="">There is insufficient account information to log you on</Message>
<Data i:nil="true" xmlns=""/>
<InnerException i:nil="true" xmlns=""/>
<HelpURL i:nil="true" xmlns=""/>
<StackTraceString i:nil="true" xmlns=""/>
<RemoteStackTraceString i:nil="true" xmlns=""/>
<RemoteStackIndex i:type="x:int" xmlns="">0</RemoteStackIndex>
<ExceptionMethod i:nil="true" xmlns=""/>
<HResult i:type="x:int" xmlns="">-2147467259</HResult>
<Source i:nil="true" xmlns=""/>
<WatsonBuckets i:nil="true" xmlns=""/>
</Win32Exception>
</detail>
</s:Fault>
我期待一个字符串数组作为响应,但我不断收到 Forbidden 并需要更多信息。我不知道需要传递哪些信息才能访问这些方法。Windows 身份验证需要什么以及如何使用 PHP 实现它?
所以这个问题通过使用来自这个 github 帐户https://github.com/microsoft/Dynamics-AX-Integration 的phpApplication 的动态集成示例得到了解决
在阅读了此处的Microsoft 文档后,我了解到需要从 azure AD 获取授权令牌,并且需要将该令牌添加到我的 curl 标头中作为 Authorization: Bearer tokenString
我没有使用 SOAPClient,而是使用 Curl 进入 Dynamics AX,因此我获得了授权并进入了。之后我遇到了另一个问题,您可以在这里找到它。现在我面临一个不同的问题;似乎我能够使用我的授权令牌承载头,但我得到:
Forbidden 1317 System.ComponentModel.Win32Exception The specified account does not exist
我创建了一个不同的帖子,以防万一我解决了我会发布我的答案,或者如果有人已经解决了它..请告诉我。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句