javamicrosoft-dynamicsdynamics-navdynamics-nav-2013

Access Dynamics NAV Webservice with Java


I am trying to access a Dynamics NAV 2013 R2 web service from Java. The web service is running and when I enter the URL in the Internet Explorer, I can see the WSDL but first I am prompted for Username and Password. On Wireshark I can see that it uses authentication based on NTLM. Sofar I was only able to open the WSDL from Internet Explorer, when I open it on Firefox, it give me a blank page and no error.

What I am trying to do is to access the Web Service from Java using the wsimport tool, but I am unable to authenticate. I have already created a folder in ~/.metro/auth and put the following line in there:

http://userfoobar:[email protected]:7047//DynamicsNAV71/WS/CRONUS%20AG/Page/PageWithCapitalization

and I am trying to access the web page with:

wsimport -d generated -s sources http://@192.168.0.170:7047/DynamicsNAV71/WS/CRONUS%20AG/Page/PageWithCapitalization

I always get the error:

[ERROR] Server returned HTTP response code: 401 for URL: http://@192.168.0.170:7047/DynamicsNAV71/WS/CRONUS%20AG/Page/PageWithCapitalization,  "http://@192.168.0.170:7047/DynamicsNAV71/WS/CRONUS%20AG/Page/PageWithCapitalization" needs authorization, please provide authorization file with read access at /home/user/.metro/auth or use -Xauthfile to give the authorization file and on each line provide authorization information using this format : http[s]://user:password@host:port//<url-path>

I have tried this both from Linux and the Windows 7 machine which runs the NAV Webservice. Do I have to perform any additional configuration in NAV? Are there any special tricks to get this to work?


Solution

  • By default Nav uses Windows Active Directory authorization. I'm not sure what wsimport do in java but credentials provided in url unlikely to work. You need to go through negotiation procedure to authorize with server or change authorization type in Nav Server Administration snap-in on server (or in configuration file).

    See here about credential types and here is how to configure server. Also see usefull post in Freddy's blog on how to connect to Nav from Java (I believe its still relevant though it's for Nav 2009).

    soapUI can handle NTLM authorization type so you can see all requests and responses through negotiation process in it's logs.