Options

Error when calling webservice with wrong url

elwin68elwin68 Member Posts: 153
edited 2011-05-04 in NAV Three Tier
Hello,

I have a problem when calling a webservice out off NAV 2009 SP1.
The following lines are used.

XmlHttpLaut.open('POST', VarURL, FALSE);
XmlHttpLaut.setRequestHeader('Content-type','text/xml; charset=utf-16');
XmlHttpLaut.setRequestHeader('SOAPAction', VarSoapaction);
XmlHttpLaut.setRequestHeader('Timeout','100000');
XmlHttpLaut.send(XmlDocLaut);

VarURL is a variable with the url of the webservice.
When VarURL has the correct url everything is working well.
When VarURL has the wrong url an error occures for the method Open.

Is it possible to catch this error in NAV so I can generate an error myself?

Thanks in advance.

Answers

  • Options
    ufukufuk Member Posts: 514
    Why do you want to catch error in Navision? If you catch the exception (outside Navision) then you can simply send this Exception message to NAV, format it as you want and return back.
    Ufuk Asci
    Pargesoft
  • Options
    elwin68elwin68 Member Posts: 153
    Hello ufuk,

    The following error occures which is not clear for a user.

    This message is for C/AL programmers.

    An exeption occured with the method Open.
    ....
    ....

    So it would be nice I can catch this error when calling the XmlHttpLaut.open method.

    And I have no code outside NAV.
  • Options
    ufukufuk Member Posts: 514
    In Navision you won't have additional information to handle this Exception. So it doesn't matter if you implement error handling in Navision or on an external platform. (In fact it will be more difficult.)
    Why don't you use switch statements based on Error Codes that display user friendly messages?
    Ufuk Asci
    Pargesoft
  • Options
    elwin68elwin68 Member Posts: 153
    Thanks for your answer.

    I'm quite new in calling webservices out of NAV.
    Is there an example so I can see how this works?

    Thanks in advance.
  • Options
    ufukufuk Member Posts: 514
    If the error raises from Navision, Exception.Message already includes Navision error.
    If not, you can play with the InnerException and Source properties of the Exception class.
    Ufuk Asci
    Pargesoft
  • Options
    krikikriki Member, Moderator Posts: 9,090
    [Topic moved from 'NAV/Navision Classic Client' forum to 'NAV Three Tier' forum]
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.