繁体   English   中英

PHP SOAPClient使用Windows身份验证背后的MS Dynamics WSDL方法

[英]PHP SOAPClient consuming MS Dynamics WSDL Methods behind Windows Authentication

我正在尝试连接到需要Windows身份验证的Web服务。 我正在用PHP编写代码,并尝试调用MS dynamics 365 wsdl方法,但我得到的只是“ Forbidden608 error code: There is insufficient account information to log you on.

我已经尝试了NTLMSoapClientNuSoap类,但是当它没有抛出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"


?>

即使使用SOAPUISOAPUI得到相同的结果

  <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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM