[英]PHP SOAPClient consuming MS Dynamics WSDL Methods behind Windows Authentication
我正在嘗試連接到需要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 = "user@dynamicsaccount.com";
$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
我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>
我期望一個字符串數組作為響應,但是我一直在被禁止,並且需要更多信息。 我不知道訪問這些方法需要傳遞什么信息。 Windows身份驗證需要什么?如何使用PHP實施它?
因此,通過使用此github帳戶https://github.com/microsoft/Dynamics-AX-Integration的 phpApplication動態集成示例解決了此問題
在這里閱讀Microsoft文檔之后,我了解到它需要從azure AD獲取授權令牌,並且需要在我的curl頭中將令牌添加為Authorization:Bearer tokenString
我不是使用SOAPClient,而是使用Curl進入Dynamics AX,因此我獲得了授權並加入了。之后,我遇到了anotehr問題, 您可以在這里找到它 。 現在,我面臨着另一個問題。 看來我能夠使用我的授權令牌承載標頭,但是卻得到了:
Forbidden 1317 System.ComponentModel.Win32Exception The specified account does not exist
我創建了一個不同的帖子,如果我解決了,我會發布我的答案,或者如果有人已經解決了..請告訴我。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.