
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
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:
I there anything I can do with any of those displayed properties or methods to aid connection?
Thanks