3-tier mgt, magic path, and WEB SERVICE tier

ReinhardReinhard Member Posts: 249
edited 2014-05-22 in NAV Three Tier
Hello,
First of all, yes, I have read all the posts about magic path, <TEMP>, 3 tier automation, etc. I'm comfortable with this.

My problem is that the same code behaves differently from the "Web Service Tier" than the regular service tier.

When I call BLOBExport from the service tier it says "Callback functions are not allowed."
When I run it from RTC, there is no callback functions though. (No prompt to save file, etc.) so everything from web service should be good, right?
Any hints would be appreciated. I'm running it as the same user in both instances. The only difference as far as I can tell is the web vs nav tier.
This is in NAV 2009 build 33729.
- Reinhard
fileLoc := tierMgt.BLOBExport(tmpBlob,'',FALSE);
///////////////
BLOBExport(VAR BLOBRef : TEMPORARY Record TempBlob;Name : Text[1024];CommonDialog : Boolean) : Text[1024]
IF NOT ISSERVICETIER THEN
  EXIT(BLOBRef.Blob.EXPORT(Name,CommonDialog))
ELSE BEGIN
  BLOBRef.Blob.CREATEINSTREAM(NVInStream);
  IF STRPOS(Name,'*') = 0 THEN
    ToFile := Name
  ELSE BEGIN
    ToFile := INSSTR(Name,Text001,1);
    ToFile := DELCHR(ToFile,'=','*');
  END;
  WHILE STRPOS(ToFile,'\')<>0 DO BEGIN
    p := STRPOS(ToFile,'\');
    ToFile := COPYSTR(ToFile, p+1);
  END;
  Path := 'C:\TEMP';
  IF NOT CommonDialog THEN
    Path := Magicpath;
  DOWNLOADFROMSTREAM(NVInStream,Text006,Path,Text009,ToFile);
  EXIT(ToFile);
END

Comments

  • kinekine Member Posts: 12,562
    I think that this is "nonsense", because if you are using webservice, you cannot download the file. To be able to download the file, there must be NAV client, which is "called-back" to download the file. If there is webservice, you cannot transfer file in this way. You need to return the content as part of the webservice call. As content of BigData parameter, or encoded as Base64 in some string parameter etc. But you cannot DOWNLOAD it (the client must save it somewhere, but when the client is your own C# code, how it will "take the file and save it"?).
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • ppavukppavuk Member Posts: 334
    Reinhard wrote:
    IF NOT ISSERVICETIER THEN
      EXIT(BLOBRef.Blob.EXPORT(Name,CommonDialog))
    END
    

    I think the thing is in ISSERVICETIER statement. Looks like webservice service does present himself as servicetier.

    Maybe it worth to try ISGUIALLOWED istead?
  • ReinhardReinhard Member Posts: 249
    kine: I should have specified that the web service is NOT trying to download the file. the server is just supposed to export the file (and then ftp it but I haven't gotten that far...) I do appreciate that you are trying to point me in the right direction; regardless though that wouldn't explain the error I'm getting, right?

    ppavuk: yes, that's correct. the web service presents itself as service tier, since it is.
    In 2009 there are four environments: Classic, RTC, NAS, and Web. Using a cominbation of GUIALLOWED and ISSERVICETIER you can identify which one you are on. Web is ISSERVICETIER AND (NOT GUIALLOWED)
    To verify, I have given your suggestion a try, but it gives the error "The EXPORT() method is obsolete" which is as expected.

    I think I'm going to convert this to run from NAS.
    But the code works fine running from RTC, it's even using the same user, so I figured web service should work as well, so that is still bugging me.

    - Reinhard
  • kinekine Member Posts: 12,562
    Reinhard, you cannot use DOWNLOADFROMSTREAM under WebService (IsServiceTier = true and GUIALLOWED = false). As I wrote, to be able to DOWNLOAD (it includes the DOWNLOADFROMSTREAM) you must use client. In case of webservices, you need to save the data to file directly on the server (createoutstream on file variable). Than you need to proces the file, but without the download functions, because there is no "where" to download...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • ReinhardReinhard Member Posts: 249
    hi kine

    ah I see. I have taken a closer look at the definition of DOWNLOADFROMSTREAM and it specifies that it is to the client.
    u need to save the data to file directly on the server (createoutstream on file variable)
    I agree with you here. This is where I was stuck, but you have pointed me in the right direction:
    viewtopic.php?f=5&t=36646&start=0

    It describes how to take a blob, create an outstream, and create a file and create an instream. Then COPYSTREAM will do the trick.

    I guess it might be nice to work this function into the 3-tier blob export function under a "if not guiallowed" section inside the ISSERVICETIER
    then the function would work in all four of the possible setups, rather than just 3.

    thanks for your help! (sorry too much coffee the last couple of days, wasn't thinking straight!)
    - Reinhard
Sign In or Register to comment.