web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Web services

(0) ShareShare
ReportReport
Posted on by 245

Hi.

 

Someone knows what's wrong with this picture in a Dynamics Nav 2009 R2 web-service test scenario.

Visual studio 2010  Service reference projekt has app.config that looks like this.

 

<?xml version="1.0" encoding="utf-8" ?>

<configuration>

    <system.serviceModel>

        <bindings>

            <basicHttpBinding>

                <binding name="TestWS_Binding" closeTimeout="00:01:00" openTimeout="00:01:00"

                    receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"

                    bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"

                    maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"

                    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"

                    useDefaultWebProxy="true">

                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"

                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />

                    <security mode="TransportCredentialOnly">

                      <transport clientCredentialType="Ntlm"/>

                    </security>                  

                </binding>

            </basicHttpBinding>

        </bindings>

        <behaviors>

          <endpointBehaviors>

            <behavior name="allowDelegation">

              <clientCredentials>

                <windows allowedImpersonationLevel="Delegation"

                        allowNtlm="true"/> 

              </clientCredentials> 

            </behavior>

          </endpointBehaviors>

       </behaviors>

      <client>

            <endpoint address="http://10.0.0.144:7047/DynamicsNAV/WS/CRONUS%20Danmark%20A/S/Codeunit/TestWS"                

                binding="basicHttpBinding" bindingConfiguration="TestWS_Binding"

                behaviorConfiguration="allowDelegation"                      

                contract="WebServiceTest.TestWS_Port" name="TestWS_Port" />                

      </client>

    </system.serviceModel>

</configuration>

 

The customsettings.config of the service has

 

<add key="WebServicesUseNTLMAuthentication" value="true"></add>

 

Everything is running on local machine. 

 

SQL server, Web server Service runs under system account.

 

When this line 

 

                      <transport clientCredentialType="Ntlm"/>

 

in app.config says "Windows" things are working.

 

When it says "Ntlm" like above this message is returned:

 

"The HTTP request is unauthorized with client authentication scheme 'Ntlm'. The a

uthentication header received from the server was 'Negotiate'."

 

Question:

 

I obviously did something wrong but how on earth can the error message say

"received from the server was 'Negotiate'.""

 

when "Negoatiate" should not be an option in the webservice part of the equation  due to the line 

<add key="WebServicesUseNTLMAuthentication" value="true"></add>

in the "customsettings.config"  and the comment in the file says "true: Use NTLM only".

 

Pointers highly appreciated.

 

Best regards.

AO

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at

    Can you please paste the C# or vb code that you wrote to access the webservice?

  • Ohlfsen Profile Picture
    245 on at

    Tnx for your interest.

    Here's the code.

    B.R AO

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using TestWebService;
    using System.Net;

    namespace TestWebService
    {
      public delegate void ObjectParameterDelegate(object value);
      class Program
      {
          static void Main(string[] args)
          {
              Console.WriteLine("Testing WebService");
              WebServiceTest.TestWS_PortClient Tester = new WebServiceTest.TestWS_PortClient();
              Tester.ClientCredentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials;
              try
              {
                  Console.WriteLine(Tester.GetTheTime());
                  Console.WriteLine();
              }
              catch (Exception Ex)
              {
                  Console.WriteLine(Ex.Message)                    ;
                  Console.WriteLine("End Exception");
              }
              Console.WriteLine("Press Any Key");
              Console.ReadKey();
          }
      }
    }

  • Suggested answer
    Community Member Profile Picture
    on at

    Hi,

    Maybe you should try this:

    Tester.ClientCredentials.Windows.ClientCredential.UserName = "YourUsername";

    Tester.ClientCredentials.Windows.ClientCredential.Password = "YourPassword";

    Tester.ClientCredentials.Windows.ClientCredential.Domain = "YourDomain";

    instead of this:

    Tester.ClientCredentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials;

  • Luc van Vugt Profile Picture
    on at

    Hi,

    What was eventually the solution to your issue?

    Thanx in advance,

    Luc

  • Ohlfsen Profile Picture
    245 on at

    Omg. So sorry I don't recall if it was the answer, so much time passed since then. Would be happy to share, if only I could remember.

    All this webservice authentication stuff, kerberos/ntlm etc can really be mind cripling some times. 

    You think you have done what the (really poor) documentation says spn wise and otherwise but still so many things can influence if it works or not depending on the environment where you have to install the stuff.

    B.R. Allan

  • Luc van Vugt Profile Picture
    on at

    Fully agree, that's why I ask ... have installed a new service (for the xth time) and now running into new things :-(

  • mmv Profile Picture
    11,471 on at

    Hi,

    As Dragan Jovanoski said, if you provide the credentials, it might work.

    You may try that solution.

    Best Regards,

    MMV

  • 4BzSoftware Profile Picture
    6,073 on at

    Hi MMV,

    SPN and Delegation in NAV2009 are difficult things and even have experience, it takes me a day for each new setup to solve new things :-( But make sure you publish the web service successfully by web browser checking.

  • Luc van Vugt Profile Picture
    on at

    True, but just wanted to know what eventually solved. It has not been shared (yet).

  • Ohlfsen Profile Picture
    245 on at

    Sometimes find myself using Powershell to test web service access.

    Can do something like this

    $proxy = new-webserviceproxy -Uri 'localhost/.../TestWS&; -usedefaultcredential

    to test default credentials or

    $cre=Get-Credentials

    $proxy = new-webserviceproxy -Uri 'localhost/.../TestWs&; -Credential $cre

    which will allow me to enter user and password

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans