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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Unanswered

Authentication issues connecting to SOAP based web service code unit in NAV

(0) ShareShare
ReportReport
Posted on by 2,724

Hi,

I have a codeunit exposed as a web service in NAV 2018.

I have built a web service in c# which has the address of this NAV service added as a service reference.

The service has resolved correctly and I can call the exposed method and run it.

My issue is on authentication.

The NAV developer has told me I can use NavUserPassword as the credential type.

My issue is that on the service I can't see where I can or how I can tell the service I'm connecting to what authentication methods I'm using and pass across the username and password inside the service.

If I run my service it is fine until it calls the method then I get the authentication error:

System.ServiceModel.Security.MessageSecurityException: The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Basic realm=""'. ---> System.Net.WebException: The remote server returned an error: (401) Unauthorized.

   at System.Net.HttpWebRequest.GetResponse()

   at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)

   --- End of inner exception stack trace ---

 

Server stack trace:

   at System.ServiceModel.Channels.HttpChannelUtilities.ValidateAuthentication(HttpWebRequest request, HttpWebResponse response, WebException responseException, HttpChannelFactory`1 factory)

   at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory`1 factory, WebException responseException, ChannelBinding channelBinding)

   at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)

   at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)

   at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)

   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)

   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)

   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

I know this is a common issue but I would love someone to give me some sample syntax or an example I can use on how to declare and pass in the authentication data.

Perhaps I need to configure this in the web.config file of the service as it is hosted in IIS?

Anything at all from someone that understands this would be greatly appreciated.

Thanks guys

I have the same question (0)
  • Kauto Profile Picture
    2,724 on at

    Can I add that when the service reference is added all I have is:

    _PORT

    _PORTCLIENT

    _PORTCHANNEL

    When I declare either of these I have the following options:

    pastedimage1600887559072v1.png

    I there anything I can do with any of those displayed properties or methods to aid connection?

    Thanks

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,371 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,806 Super User 2026 Season 1

#3
AndrewThomas81 Profile Picture

AndrewThomas81 1,371

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans