Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
570 views
in Technique[技术] by (71.8m points)

iis - NTML Authentication with PHP to Navision SOAP webservice

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.

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!

question from:https://stackoverflow.com/questions/65921846/ntml-authentication-with-php-to-navision-soap-webservice

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

https://techcommunity.microsoft.com/t5/iis-support-blog/windows-authentication-http-request-flow-in-iis/ba-p/324645


Update 30/1/21

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

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...