Call to NAV Web Service from Classic works from RTC don't

PureHeartPureHeart Member Posts: 190
edited 2009-09-24 in NAV Three Tier
](*,) ](*,) ](*,)
Please Help I'm Desperate!
I've done some coding in the classic to call a NAV 2009 codeunit function exposed as web service...
  XmlHttp.open('POST','http://localhost:7047/' + NAVServerName + '/ws/' + Company.Name + '/Codeunit/' +
               WebService."Service Name",0);

  XmlHttp.setRequestHeader('Content-Type','text/xml; charset=utf-8');
  XmlHttp.setRequestHeader('SOAPAction','ConvertWAMPS2Vendor');

  //The last parameter set to zero allows to wait till webservice finishes
  XmlHttp.setTimeouts(10000,10000,10000,0);

  XmlHttp.send('<?xml version="1.0" encoding="utf-8"?>' + 
               '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">' +
               '<soap:Body><ConvertWAMPS2Vendor xmlns="urn:microsoft-dynamics-schemas/codeunit/' +
               WebService."Service Name" + '">' +
               '</ConvertWAMPS2Vendor></soap:Body></soap:Envelope>');

  XmlDoc.async := FALSE;
  XmlDoc.load(XmlHttp.responseBody);

  XmlDoc.save('C:\' + Company.Name + 'testwebresponse.xml');

  IF XmlHttp.status <> 200 THEN BEGIN

    XmlNode := XmlDoc.selectSingleNode(ErrorDetailPath);

    IF NOT ISCLEAR(XmlNode) THEN
      MESSAGE(Company.Name + ': ' + XmlNode.text)
    ELSE
      MESSAGE(Company.Name + ' Http Error ' + ' ' + FORMAT(XmlHttp.status) + ': ' + XmlHttp.statusText);

  END ELSE BEGIN

    //ALL OK

  END;

This works fine if I try to call it from the Classic Client but when instead I call it from the RTC I have this message:

- <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"&gt;
- <s:Body>
- <s:Fault>
<faultcode xmlns:a="urn:microsoft-dynamics-schemas/error">a:Microsoft.Dynamics.Nav.Types.NavDatabasePasswordException</faultcode>
<faultstring xml:lang="en-GB">The user ID and password are invalid. Try again.</faultstring>
- <detail>
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">The user ID and password are invalid. Try again.</string>
</detail>
</s:Fault>
</s:Body>
</s:Envelope>

Why is doing that?
I don't understand please help me to solve and understand why!!!!

THANKS!
Why don't you try my compare tool?
http://www.mibuso.com/dlinfo.asp?FileID=1123

Comments

  • ara3nara3n Member Posts: 9,255
    When you run the code XmlHttp is instantiated at the service tier and thus uses the service tier account to make the authenication.

    XmlHttp.open( has additional parameter for userID and password that you can pass, Or instantiate the XmlHttp at client side so it uses users credentials.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • PureHeartPureHeart Member Posts: 190
    Ok Thanks but I've then added the "NT AUTHORITY\NETWORK SERVICE" account to the database (which is the one used by the NAV Server) but it still doesn't work?!
    Any Idea why?
    Why don't you try my compare tool?
    http://www.mibuso.com/dlinfo.asp?FileID=1123
  • ara3nara3n Member Posts: 9,255
    change your code and pass login and password in Open function first.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • PureHeartPureHeart Member Posts: 190
    Yes Thanks It works :D:D
    But Do you know if it is possible to be able to make the call passing the current user logged into the system instead of having an extra windows account to do this?
    Why don't you try my compare tool?
    http://www.mibuso.com/dlinfo.asp?FileID=1123
  • ara3nara3n Member Posts: 9,255
    change the .code to

    create(XmlHttp,true,true);
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • PureHeartPureHeart Member Posts: 190
    :D:D
    You are the best thank you so much!
    But now I remember why I didn't create the automation on the client...If I replace in the server address "localhost" with the name of the server then it doesn't work :(:(
    Giving me the error:

    Http Error 401: Unauthorized

    How do I fix it?
    Why don't you try my compare tool?
    http://www.mibuso.com/dlinfo.asp?FileID=1123
  • ara3nara3n Member Posts: 9,255
    Are you part of Domain? If Yes, try to connect through VPN first.

    Can you access the WSDL through Internet Explorer?


    Can you try the ip address instead?
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • PureHeartPureHeart Member Posts: 190
    Yes I'm part of a Domain and I'm connected through VPN but I've loaded everything on my laptop so I have SQL running and the NAV Server running on my machine....

    I can access the WSDL from ie using the name of the machine without any problem, I've also installed another instance of the NAV Server on another machine with another SQL database and I can access from ie the WSDL of that machine using the computer name but it doesn't work when I do the same via code :(:(:(!

    I haven't tried with the IP Address but I'll try later on when in the Office....but why does work from ie and not from code what is different?

    Thanks Again!
    Why don't you try my compare tool?
    http://www.mibuso.com/dlinfo.asp?FileID=1123
  • PureHeartPureHeart Member Posts: 190
    PureHeart wrote:
    Yes I'm part of a Domain and I'm connected through VPN but I've loaded everything on my laptop so I have SQL running and the NAV Server running on my machine....

    I can access the WSDL from ie using the name of the machine without any problem, I've also installed another instance of the NAV Server on another machine with another SQL database and I can access from ie the WSDL of that machine using the computer name but it doesn't work when I do the same via code :(:(:(!

    I haven't tried with the IP Address but I'll try later on when in the Office....but why does work from ie and not from code what is different?

    Thanks Again!

    Anyone Please any idea? ](*,) ](*,)
    Why don't you try my compare tool?
    http://www.mibuso.com/dlinfo.asp?FileID=1123
  • PureHeartPureHeart Member Posts: 190
    Ok that was me being stupid....

    We have a proxy server in the Office...http://support.microsoft.com/kb/291008

    If can help someone you have to use the "setproxy" instruction before making the call! \:D/
    Why don't you try my compare tool?
    http://www.mibuso.com/dlinfo.asp?FileID=1123
Sign In or Register to comment.