Running XMLport via code in RTC

ShaggsShaggs Member Posts: 36
edited 2011-11-02 in NAV Three Tier
I'm using 2009 R2 RTC, and I'm trying to run an xmlport via code. I have some code that runs just fine, so long as I'm running it from the same machine the service tier resides on. When I run it from a different machine, it does not work.

The code I am trying is:
TF.WRITEMODE(FALSE);
  TF.TEXTMODE(TRUE);
  TF.OPEN(tmpSourceFile);
  TF.CREATEINSTREAM(IS);
  ImportXMLP.SETSOURCE(IS);
  ImportXMLP.IMPORT;

TF is a File
IS is an instream

It is failing at the line TF.OPEN(tmpSourceFile);

Can anyone offer assistance here?

Comments

  • deV.chdeV.ch Member Posts: 543
    Your need to upload your file to the servicetier, since this code is executed on servicetier. to do this use the existing functions in codeunit "3-Tier Automation Mgt." (419)
    The function you need is SilentUpload()
  • naviannavian Member Posts: 39
    deV.ch; Is the 'SilentUpload' thing needed if the file is located in a shared folder that everybody has access to (including the service tier) (eg. the same path for all users/machines)?
  • deV.chdeV.ch Member Posts: 543
    i guess it's not needed, if you have access to the file from servicetier then an upload would be useless. There's a function to check if it's a network path: IsValidUNC()
  • naviannavian Member Posts: 39
    Ok, thanks deV.ch.
    I will do some testing...
    I guess using 'SilentUpload' would be considered 'best practice'.
  • ShaggsShaggs Member Posts: 36
    My codeunit 419 doesnt have a function SilentUpload. I have checked a few versions of 2009:
    2009-R2 (NAVW16.00.01)
    2009-SP1 (NAVW16.00.01)
    2009 (NAVW16.00)

    And none of them have it.

    I'm going to try File.UPLOADINTOSTREAM. It prompts the user, but I might just restructure the code around it to compensate.
  • deV.chdeV.ch Member Posts: 543
    Heres the function from the CU

    SilentUpload(ClientFilePath : Text[1024];VAR ServerFilePath : Text[1024]) Status : Boolean
    // DACH0001.begin
    IF ISCLEAR(FileObject) THEN
      CREATE(FileObject, TRUE, TRUE);
    
    Ext := FileObject.GetExtensionName(ClientFilePath);
    ClientTempFilePath := ClientTempFileName('',Ext);
    ClientTempFile := FileObject.GetFileName(ClientTempFilePath);
    FileObject.CopyFile(ClientFilePath,ClientTempFilePath,TRUE);
    
    ServerFilePath := ServerTempFileName('',Ext);
    
    Status := UPLOAD('',Magicpath,'',ClientTempFile,ServerFilePath);
    
    // DACH0002.begin
    //IF FileObject.FileExists(ClientTempFilePath) THEN
    //  FileObject.DeleteFile(ClientTempFilePath);
    // DACH0002.end
    EXIT(Status);
    // DACH0001.end
    

    and Magitpath:
    Magicpath() : Text[1024]
    EXIT('<TEMP>');   // MAGIC PATH makes sure we don't get a prompt
    
  • mdPartnerNLmdPartnerNL Member Posts: 802
    Just downloaded the DE database. Those are nice functions. =D>
Sign In or Register to comment.