Webservices 2009 R2 - defaultcredentials causes err 500

Peter76Peter76 Member Posts: 10
edited 2013-02-12 in NAV Three Tier
I have a web service set up for NAV 2009 R2. It works well when I am trying to access it through the browser. However, when I am trying to consume the webservice in C# (code below), I am getting an internal server error 500 and the event log states that I need delegation/impersonation setups. The weird thing is that the SQL Server, Web Service, and NST are all on the same computer. I am using my domain user as the services account for all three services (doesn't matter if I switch those to Network Service). I do not have access to the domain to set up delegation, so I didn't try this yet. But this should not even be happening in my eyes. When I create credentials using a windows login and password and assign it as the credentials, I have no problem accessing the webservice. Does anyone have any ideas please?
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(CreateURL(_SystemService));
request.UseDefaultCredentials = true; // THIS IS THE ISSUE?

request.Method = "GET";
request.ContentType = "text/xml; charset=utf-8";
request.Accept = "text/xml";

WebResponse response = await request.GetResponseAsync();
StreamReader reader = new StreamReader(response.GetResponseStream(), System.Text.Encoding.UTF8);

Just as a sidenote: Yes, I know I could add the service as a reference, but it doesn't work in this scenario, so I have to work through "GET" and "POST" to communicate with the service. As I said - it all works fine if I use defined credentials, which I can't really do in the deployed production environment.
Peter Zentner
NAV Practice Manager at Clients First Business Solutions

Did you check out our free training videos at www.dynamics-nav-training.com?
Look at our blogs.

Comments

  • ppavukppavuk Member Posts: 334
    Not sure, but in my experience this do require SPN's set up even if everything on same machine within domain.
  • Peter76Peter76 Member Posts: 10
    I have to give that a try tomorrow, when I am actually in the domain again. However, one thing that speaks against requiring SPNs is that the webservice is easily accessed through the browser as well as when I use specific credentials. Only the "UseDefaultCredentials" doesn't work, which is essentially the same way as the web browser authenticates against the webservice, I would assume.
    Peter Zentner
    NAV Practice Manager at Clients First Business Solutions

    Did you check out our free training videos at www.dynamics-nav-training.com?
    Look at our blogs.
  • ppavukppavuk Member Posts: 334
    is defaultcredentials isn't windows authentication? I think it must be, but I might be wrong. So, if it is windows authentication - you will get error, as something in your setup preventing you to connect to webservice under windows account.
Sign In or Register to comment.