Authentication Error on consuming web service reference in MSD axapta

If you are getting Authentication Error on consuming web service reference in axapta like this

"The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Negotiate'. The remote server returned an error: (401) Unauthorized”

Then you need to check application configuration file in service reference folder from application folder.

You need to check <behaviors /> tag you can replace with following code.

<behavior name="allowDelegation">
<clientCredentials>
<windows allowedImpersonationLevel="Delegation" />
</clientCredentials>
</behavior>

Then you need to check security tag.

Previous code

<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>

You need to replace with this code..

<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>

Then include behaviorConfiguration="AllowDelegation" property in end point tag.

<endpoint address="" behaviorConfiguration="allowDelegation" binding="basicHttpBinding"....>

I hope your problem get resolved.