Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

Query Regarding Web Service-NAV2009R2

Posted on by Microsoft Employee

Hi All,

i am trying to update one newly created table called "GLentrymap" from one Navision DB to other (NAV to NAV)using web services and i have published one codeunit as web service in my NAV DB2(we can call it as  NAV_Dest) and that codeunit consist a simple function called"upadateglentrymap" just to update  the data in respective table(GLentrymap) and have written one more codeunit in NAV DB1 (NAV_Source) ,So when i ran this codeunit i am getting error like "Http error 401: Unauthorized ".

 so pls help on that!!  

here is my code for NAV DB1 (NAV_Source): 


IF ISCLEAR(XmlHttp) THEN
CREATE(XmlHttp, TRUE,TRUE);
IF ISCLEAR(XmlDoc) THEN
CREATE(XmlDoc);
XmlDoc.async(FALSE);

//call webservice updateGLentrymap table
XmlHttp.open('POST','localhost/.../codeunittest',FALSE,
'username','pass');
XmlHttp.setRequestHeader('Content-Type', 'text/xml; charset=utf-8');
XmlHttp.setRequestHeader('SOAPAction', 'upadateglentrymap');
//<?xml version="1.0" encoding="utf-8"?>

XmlHttp.send(
'<soapenv:Envelope xmlns:soapenv="schemas.xmlsoap.org/.../envelope" '+
' xmlns:nav="urn:microsoft-dynamics-schemas/codeunit/codeunittest"> '+
'<soapenv:Body> '+
'<nav:updateGLenrymap> '+
'<nav:no>'+FORMAT(GLEntryMap."G/L Entry no")+'</nav:no> '+
'<nav:mapping_Account>'+GLEntryMap."Mapping account"+'</nav:mapping_Account> '+
'</nav:updateGLenrymap> '+
'</soapenv:Body> '+
'</soapenv:Envelope>');
// XmlHttp.send(soap);
//MESSAGE('%1',GLEntryMap."G/L Entry no");
IF XmlHttp.status <> 200 THEN
ERROR('Http error '
+ FORMAT(XmlHttp.status)+': '+XmlHttp.statusText + ' ' +XmlHttp.responseText);
XmlDoc.load(XmlHttp.responseXML);

MESSAGE(XmlHttp.statusText+'\\'+XmlDoc.text);

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Query Regarding Web Service-NAV2009R2

    hey Stefano Demiliani,

    after removing credential now i am getting status as "internal server Error".So pls help on this!!

  • Suggested answer
    Stefano Demiliani Profile Picture
    Stefano Demiliani 37,162 Most Valuable Professional on at
    RE: Query Regarding Web Service-NAV2009R2

    Yes I mean that. Try removing credentials in the OPEN line.

    Something like:

    XmlHttp.open('POST','localhost/.../codeunittest',FALSE);

    It should be executed as the current user.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Query Regarding Web Service-NAV2009R2

    correctly configured means?? i can login to database using this username and password !!

  • Suggested answer
    Stefano Demiliani Profile Picture
    Stefano Demiliani 37,162 Most Valuable Professional on at
    RE: Query Regarding Web Service-NAV2009R2

    Is the username correctly configured in the target NAV?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Query Regarding Web Service-NAV2009R2

    yes, NTLM Authentication value is set as TRUE after that also i am getting same error.

  • Suggested answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: Query Regarding Web Service-NAV2009R2

    Did you enable the NTLM Authentication on the service, if not please set that to true.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans