Consuming NAV web service through NAV - error 401

AK
Member Posts: 226
I've created a simple NAV 2009 web service (SPNEGO authentication) and can access it with Webservice Studio when logged in at the NAV server. I've also some C/AL code to access the same web service, but when run in the classic client at the server, I get the "Http Error 401: Unauthorized" error.
The user running Webservice Studio and the classic client are the same, it is in fact the same session on the server. I can even access the web service from a different PC with a different user with Webservice Studio.
Relevant code (stolen from the download section):
As far as I understand, when running the code in classic client, it will log on to the web service as the user who is logged into the client, right? And this also happens when using WebService Studio. The user should be the same in both cases, but it works only in the latter.
Has someone an idea what might be wrong?
The user running Webservice Studio and the classic client are the same, it is in fact the same session on the server. I can even access the web service from a different PC with a different user with Webservice Studio.
Relevant code (stolen from the download section):
IF ISCLEAR(XmlDoc) THEN CREATE(XmlDoc); IF ISCLEAR(XmlHttp) THEN CREATE(XmlHttp); XmlHttp.open('POST','http://996rzdb3:7047/MicrosoftDynamicsNAVServer/WS/'+OtherCompany+'/Codeunit/RunObject',0); XmlHttp.setRequestHeader('Content-Type', 'text/xml; charset=utf-8'); XmlHttp.setRequestHeader('SOAPAction','RunObject'); XmlHttp.setTimeouts(10000,10000,10000,100000); XmlHttp.send('<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">' + '<soap:Body><RunObject xmlns="urn:microsoft-dynamics-schemas/codeunit/RunObject">' + '<objectType>'+ObjectType+'</objectType><objectID>'+FORMAT(ObjectID)+'</objectID>'+ '</RunObject></soap:Body></soap:Envelope>'); IF XmlHttp.status <> 200 THEN MESSAGE('Http Error ' + ' ' + FORMAT(XmlHttp.status) + ': ' + XmlHttp.statusText);
As far as I understand, when running the code in classic client, it will log on to the web service as the user who is logged into the client, right? And this also happens when using WebService Studio. The user should be the same in both cases, but it works only in the latter.
Has someone an idea what might be wrong?
0
Comments
-
For future reference:
The above code uses ServerXMLHTTP automation server, which doesn't use kerberos authentication by default (https://support.microsoft.com/en-us/help/314404/how-to-use-kerberos-with-the-serverxmlhttp-component-in-msxml).
If using XMLHTTP instead, it works as expected.0 -
You didn't pass Network credentials, use those credentials and try it again0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions