Problem using a WebService from a Web App

Hi everyone,

I’m finding an issue with the upgrade and migration of NAV. In the old server, I was running a self developed WebApp, that was consuming different webServices from NAV2013 without any problem. The WebApp is develoepd in C#.

Now, I’ve migrated NAV to a new server, and upgraded to NAV2018. In the WebApp, I’ve changed the references to the webService in the new server. I’m connecting to the app forms without any problem, but when it needs to use any of the webServices, I found this error in the Event Viewer:

Event code: 3005 
Event message: Excepción no controlada. 
Event time: 17/04/2018 9:33:56 
Event time (UTC): 17/04/2018 7:33:56 
Event ID: 1377ba09b69b4676912727c7c2a74b71 
Event sequence: 12 
Event occurrence: 1 
Event detail code: 0 
 
Application information: 
    Application domain: /LM/W3SVC/2/ROOT/Picking-1-131684240033263190 
    Trust level: Full 
    Application Virtual Path: /Picking 
    Application Path: C:\Websites\Picking\ 
    Machine name: SRV-DC01 
 
Process information: 
    Process ID: 4724 
    Process name: w3wp.exe 
    Account name: IIS APPPOOL\Website 
 
Exception information: 
    Exception type: WebException 
    Exception message: Error de la solicitud con el código de estado HTTP 401: Unauthorized.
   en System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
   en System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
   en WebService.PDAMgt.ExistePicking(String numPicking)
   en Picking.Entrada.txtCodigo_TextChanged(Object sender, EventArgs e)
   en System.Web.UI.WebControls.TextBox.OnTextChanged(EventArgs e)
   en System.Web.UI.Page.RaiseChangedEvents()
   en System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

 
 
Request information: 
    Request URL: http://srv-dc01:8090/Picking/Entrada.aspx 
    Request path: /Picking/Entrada.aspx 
    User host address: 192.168.2.140 
    User:  
    Is authenticated: False 
    Authentication Type:  
    Thread account name: IIS APPPOOL\Website 
 
Thread information: 
    Thread ID: 7 
    Thread account name: IIS APPPOOL\Website 
    Is impersonating: False 
    Stack trace:    en System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
   en System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
   en WebService.PDAMgt.ExistePicking(String numPicking)
   en Picking.Entrada.txtCodigo_TextChanged(Object sender, EventArgs e)
   en System.Web.UI.WebControls.TextBox.OnTextChanged(EventArgs e)
   en System.Web.UI.Page.RaiseChangedEvents()
   en System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
 
 
Custom event details: 

The access to Nav is navUserPassword.

Any hint with this issue? If any info is needed, I will answer immediately, I’m quite desperate with this…

Thank you all

Hi Aitor,

This is a permission problem. Your user is not getting authorized by the NAV server.

Thanks for your answer Erik. The thing, is that i am using this sentence for the credentials:

ws.Credentials = new System.Net.NetworkCredential("betea", "xxxxxx", "localhost");

Where “betea” is a Nav user

I hope this is NOT an actual code example? Never hardcode passwords!

But I assume that you’ve already tested that you’re able to use web services with your NAV 2018 in general? And is the betea user able to login “normally”?

Hi Erik,

I think I’ve solved the issue. The thing was that I should use an other definition of the credentials method, becasue of the authentication mode. For the new server, it was changed to NavuserPassword, so, the user I was introducing, didn’t have a domain, so I only need to pass 2 parameters to the NetworkCredential method.

Now it seems it’s working, at least I don’t have the autorization error. I will change all the references of the development, and see if it works.

What do you mean with harcoding password? In the development? What is your advise?

Thank you again!

Great it worked. So the error message was correct, a permission problem.

I mean that hardcoding a password into any kind of source code or scripts should be = jail time! [emoticon:4191f5ee34e248a29fa0dbe8d975f74a]

And in you case, even if you did change it to “xxxxx” then the password you wrote is most likely already cached by search engines etc. - so better change, especially if used else where.

Passwords should only exist in encrypted fields. Even if the user is completely handicapped permission wise.

O, understtod. I was quite desperate with this issue, I spent hours on it, so I didn’t realise that.

Thank you again!!!