When I expose a codeunit to web service the automation ...

kirkostaskirkostas Member Posts: 127
edited 2011-09-09 in NAV Three Tier
When I expose a codeunit to web service the automation not work and cannot be created.
I have a codeunit that works fine with an automation that calls a custom dll compiled from visual basic 6 sp6.
We never had a problem with that and it worked as a charm. Now we decided that we want this functionality as a web service and when I exposed the codeunit the automation crash and cannot be created. Why?
Ok := NOT ISCLEAR(automation);
IF NOT Ok THEN
  Ok := CREATE(automation, FALSE, ISSERVICETIER);

IF Ok THEN BEGIN
  returnvalue := automation.function(variable1,variable2,variable3,variable4);
  CLEAR(automation);
END;

EXIT(returnvalue);

When I run it through Classic or RTC the Ok is TRUE which means the automation was created succesfully. When call it from Web Service the Ok is FALSE.

The names automation, function, returnvalue, variable1,2,3 and 4 are hypothetical but the structure of the code is exactly the same.
kirkostas

Comments

  • mikmik Member Posts: 79
    Hi,

    is it possible that ISSSERVICETIER is true? Should be true because the WS is a service. So you need to create the automation on the server.
    CREATE(Automation [,NewServer] [,OnClient])
    

    try
    Ok := NOT ISCLEAR(automation);
    IF NOT Ok THEN
      Ok := CREATE(automation, FALSE, FALSE);
    

    With kind regards
    mik
  • kirkostaskirkostas Member Posts: 127
    It worked, but why?

    So for the classic is false, for the web service is false but for the RTC is true?
    kirkostas
  • BeliasBelias Member Posts: 2,998
    the "onclient" parameter is ignored in classic client (thus, when you run on classic it's always true).
    when you run on RTC or WS, the parameter is always true in your case (because you set ISSERVICETIER as the third parameter.).

    i think that the client from where you consumed the WS couldn't create the automation (because it's not installed on that pc?).

    this link could help:
    http://dynamicsuser.net/blogs/waldo/archive/2009/12/01/where-am-i.aspx
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • mikmik Member Posts: 79
    Hi!
    i think that the client from where you consumed the WS couldn't create the automation (because it's not installed on that pc?)

    I can't believe that it would work even if you install the automation on the client. The automation must be on the machine where the code is running. In your case on the service tier.

    With kind regards
    mik
  • BeliasBelias Member Posts: 2,998
    mik wrote:
    I can't believe that it would work even if you install the automation on the client. The automation must be on the machine where the code is running. In your case on the service tier.
    :-k I've never tried it, so i guess you're right.
    but I've a question:
    example:
    i have excel on my pc, but there's no excel on the pc of the service tier. thus i program my automation to run "onclient", that is, on my client pc. In that case, you don't need to have excel on service tier, isn't it?
    so, why does't work the same way for webservices, too? I've not much experience with webservice, but if i tell nav that the automation must run on client, it HAVE to run on client...what am i missing? :roll:
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • mikmik Member Posts: 79
    Hi!

    hmmm ... :-k

    I think we need someone who knows the architecture of this behavior.
    But I would guess that the excel automation in your case is not started from the service tier. Instead the RTC will do that work.

    But I repeat myself ... hmmmm :-k

    greetings

    With kind regards
    mik
  • deV.chdeV.ch Member Posts: 543
    obviously you can't run on client when you are using webservice, because the client would be the consuming machine. So you need to have your components installed on the webservice machine! This is by design, i mean you could invoke a WS-call from a linux machine, or even a phone... so of course you need to have all installed on the webservice machine AND you need to create the automation with OnClient= false.

    I've done code that is using the automation on client side if its classic, and on server side if its RTC/Webservice. this works fine:
    CREATE(ftp,TRUE,NOT ISSERVICETIER);
    

    btw: i guess if you are using webservice the OnClient is ignored because its both Client&Server. so you could also have a TRUE for OnClient parameter and it would have the same effect. I'am using the "NOT ISSERVICETIER" because we only use classic & webservices on that project, so this code makes more sense for me, but a TRUE would work too i guess.
  • BeliasBelias Member Posts: 2,998
    It does make sense now, thanks for clarifying!
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
Sign In or Register to comment.