使用PHP对Navision SOAP Web服务进行NTML身份验证 [英] NTML Authentication with PHP to Navision SOAP webservice

查看:71
本文介绍了使用PHP对Navision SOAP Web服务进行NTML身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在开发一个付款网关,该网关必须将订单发送到将对其进行管理的Navision.在Web服务中,启用了 NTML 身份验证,因此首先必须扩展本机类 SoapClient .为此,我在网络上找到了足够的文档 https://thomas.rabaix.net/articles/using-soap-php-with-ntlm-authentication ,可以扩展该本机类.

I'm currently developing a payment gateway that has to send the order to Navision where it will be managed. In the webservice the NTML authentication is enabled so first it is necessary to extend the native class SoapClient. For it I have found enough documentation in the web https://thomas.rabaix.net/articles/using-soap-php-with-ntlm-authentication that allows to extend this native class.

现在该帖子中公开的代码不会先返回 xslm .

Now the code exposed in that post does not return me the xslm first.

在这种情况下,这就是我的代码

In this case this would be my code

            define("USERPWD", "user:password");

            require_once("NTLMStream.php");
            require_once("NTLMSoapClient.php");

            
            stream_wrapper_unregister('http');
            
            stream_wrapper_register('http', 'NTLMStream') or die("Failed to register protocol");
            
            // Initialize Soap Client  
            $url = "http://ipaddress:port/DynamicsNAV1_test/WS/enterprise/Codeunit/SalesEnterprise?WSDL";
            $uri = "urn:microsoft-dynamics-schemas/codeunit/SalesEnterprise";

            $params = [
                'stream_context' => stream_context_create([
                       'ssl' => [
                        'verify_peer'=>false, 
                        'verify_peer_name'=>false, 
                        'allow_self_signed'=>true,
                    ]]),
                'cache_wsdl'=> WSDL_CACHE_NONE,
                'trace' => 1,
            ];

            $client = new NTLMSoapClient($url, $params);
            
            stream_wrapper_restore('http');

如您所见,我已经放弃了该作者用于定义凭据的类.

As you can see I have dispensed with the classes used by this author to define the credentials.

最后,代码返回以下错误:

inally the code returns the following error:

SOAP Fault: (faultcode: WSDL, faultstring: SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://ipaddress:port/DynamicsNAV1_test/WS/Enterprise/Codeunit/SalesEnterprise?WSDL' : Document is empty).

如有需要,我很乐意提供更多信息.提前非常感谢!

I will be happy to provide more information if needed. Many thanks in advance!

推荐答案

从NTLM握手获得的前2个响应是没有主体的401,第三个响应如果成功通过身份验证,将包含200和响应.

The first 2 responses you get from an NTLM handshake are 401's with no body, the 3rd response if successfully authenticated will contain the 200 and response.

更新30/1/21

自从我使用Php已经有一段时间了,但是id从这篇文章开始,它显示了如何从shell手动执行NTLM curl,然后如何从php curl重复相同的命令-

Its been a while since ive used Php, but id start with this post that shows how to manually do the NTLM curl from the shell then how to repeat that same command from php curl - curl with ntlm authentication works in command line but not inside php

此SO搜索的前几个答案中也有一些块: https://stackoverflow.com/search?q = NTLM + PHP + curl

Also there are some nuggets in the top few answers of this SO search: https://stackoverflow.com/search?q=NTLM+PHP+curl

这篇关于使用PHP对Navision SOAP Web服务进行NTML身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆