8 Replies Latest reply on Apr 26, 2009 10:15 PM by Mark Richards

    FTPing a file from iSeries IFS

    Mark Richards Newbie

      Hi Guys,

      This is a 2 part question.

       

      1) Can any body help me with an example of how to use the FTP Component to access the iSeries IFS.

      I have the following in my xml config

       

       

      <camel:from uri="ftp://username@host/root/env/DEVE/FileTransfer/*.txt?password=pword" />

      <camel:to uri="file://E:/iseries/FileTransfer/DEVE/>

       

      I get the following in the logs. 

       

      FtpConsumer - Connected and logged in to ftp://username@host:21

      FtpConsumer - Unsupported type of FTPFile: username        24576 21/08/07 17:19:28 *FILE      INVOKE (not a file or directory). It is skipped.

      FtpConsumer - Unsupported type of FTPFile: username      3854336 21/08/07 17:19:29 *FILE      JUSRC (not a file or directory). It is skipped.

      FtpConsumer - Unsupported type of FTPFile: username     10514432 21/03/09 19:54:27 *FILE      MIEADM60 (not a file or directory). It is skipped.

      FtpConsumer - Unsupported type of FTPFile: username     10645504 25/03/09 20:00:47 *FILE      MIEADM60R (not a file or directory). It is skipped.

      FtpConsumer - Unsupported type of FTPFile: username      6320128 21/03/09 19:52:21 *FILE      MIEADM601 (not a file or directory). It is skipped.

      FtpConsumer - Unsupported type of FTPFile: username     13922304 21/03/09 19:54:10 *FILE      MIEMETA60 (not a file or directory). It is skipped.

      FtpConsumer - Unsupported type of FTPFile: username     11563008 21/03/09 19:52:46 *FILE      MIEMETA601 (not a file or directory). It is skipped.

      FtpConsumer - Unsupported type of FTPFile: username     14708736 25/03/09 20:01:18 *FILE      MIEMETA61R (not a file or directory). It is skipped.

      FtpConsumer - Unsupported type of FTPFile: username        24576 21/08/07 17:19:28 *FILE      MVXRLA (not a file or directory). It is skipped.

      FtpConsumer - Unsupported type of FTPFile: username        24576 21/08/07 17:19:28 *FILE      MVXSQL (not a file or directory). It is skipped.

      FtpConsumer - Unsupported type of FTPFile: username    100179968 21/03/09 19:55:05 *FILE      MWP60 (not a file or directory). It is skipped.

      FtpConsumer - Unsupported type of FTPFile: username    103833600 25/03/09 19:59:57 *FILE      MWP60R (not a file or directory). It is skipped.

      FtpConsumer - Unsupported type of FTPFile: username     86007808 21/03/09 19:51:57 *FILE      MWP601 (not a file or directory). It is skipped.

      FtpConsumer - Unsupported type of FTPFile: username        81920 21/08/07 17:19:29 *FILE      STRPGM (not a file or directory). It is skipped.

      FtpConsumer - Unsupported type of FTPFile: username        24576 21/08/07 17:19:28 *FILE      SYSINFO (not a file or directory). It is skipped.

      FtpConsumer - Unsupported type of FTPFile: username        45056 21/08/07 17:19:29 *FILE      VERINF (not a file or directory). It is skipped.

       

      These are iSeries library system files, not the ifs directory I want to conect to.

       

      If I use a windows command prompt to run ftp to check the files.

       

      I can use  "quote site namefmt 1" command to use the ifs.

      Which I can then navigate as required to get file I need.

       

       

      Has anybody implemented / experimented using ftp on the as400 from camel?

       

      Do you know how to get ifs files?

       

      I would use jt400 component, but I'm getting  org.apache.camel.NoSuchEndpointException: No endpoint could be found for: jt400:// ..... please check your classpath contains the needed camel component jar.

       

      Which I'll be asking a seperate question for.

       

       

      Cheers and Thanks in advance,

      Mark

        • 1. Re: FTPing a file from iSeries IFS
          Ulhas Bhole Novice

          jt400 component is not yet supported in FUSE Mediation Router. What version of Mediation Router are you using?

           

           

          Ulhas

           

          Edited by: ubhole on Apr 23, 2009 10:37 AM

          • 2. Re: FTPing a file from iSeries IFS
            Mark Richards Newbie

            Hi Ulhas,

             

            I'm using 1.5.3.0

             

            Cheers

            Mark

            • 3. Re: FTPing a file from iSeries IFS
              Mark Richards Newbie

              Hi Guys,

               

              Just did a quick test using commons ftp client, specifying config as as400, and I get the listing I require.  See code below

               

              I'm just experimenting with creating a bean to allow me to set the option

              ftpClientConfig. 

              Is there an example of how to implement this?  Do I need my bean to extend ftpClientConfig, or have it as a property.

              Is there test case I could see for this?

               

              Cheers

              Mark

               

              FTPClient f=new FTPClient();

              FTPClientConfig conf = new FTPClientConfig(FTPClientConfig.SYST_AS400);

                 

              f.configure(conf);

              try {

                   f.connect("HOSTNAME");

                   f.login("USERID","PASSWORD");

                   FTPFile[] ftpfiles = f.listFiles("/M3BE/env/DEVE/MvxFileTransfer/Toll_Priority/Manifest/.camel/");

               

                   for (int i =0; i < ftpfiles.length; i++){

              System.out.println(ftpfiles[i].toString());

                   }

                    

              } catch (SocketException e) {

                        // TODO Auto-generated catch block

                        e.printStackTrace();

                   } catch (IOException e) {

                        // TODO Auto-generated catch block

                        e.printStackTrace();

                   }

                    

               

              USERID           63 10/03/09 11:05:24 *STMF      /M3BE/env/DEVE/MvxFileTransfer/Toll_Priority/Manifest/.camel/1_09MAR10110524.txt

              USERID           63 10/03/09 11:10:02 *STMF      /M3BE/env/DEVE/MvxFileTransfer/Toll_Priority/Manifest/.camel/1_09MAR10111002.txt

              USERID           63 10/03/09 11:04:51 *STMF      /M3BE/env/DEVE/MvxFileTransfer/Toll_Priority/Manifest/.camel/1_09MAR10110451.txt

              USERID           63 10/03/09 11:11:42 *STMF      /M3BE/env/DEVE/MvxFileTransfer/Toll_Priority/Manifest/.camel/2_09MAR10111142.txt

              USERID           63 10/03/09 11:17:54 *STMF      /M3BE/env/DEVE/MvxFileTransfer/Toll_Priority/Manifest/.camel/2_09MAR10111754.txt

              USERID           63 10/03/09 11:31:57 *STMF      /M3BE/env/DEVE/MvxFileTransfer/Toll_Priority/Manifest/.camel/2_09MAR10113157.txt

              USERID           63 12/03/09 16:00:08 *STMF      /M3BE/env

              • 4. Re: FTPing a file from iSeries IFS
                Ulhas Bhole Novice

                I think what you need is to inject FTPClientConfig which takes in SYST_OS400 as constructor argument in your camel context.

                 

                Something like

                 

                   

                 

                in your camel spring bean should work for you.

                 

                /Ulhas

                • 5. Re: FTPing a file from iSeries IFS
                  Mark Richards Newbie

                  Thanks Ulhas,

                   

                   

                   

                  I have the following in my spring.xml

                   

                   

                   

                   

                   

                   

                   

                  When I run it I get the following

                   

                   

                   

                  2009-04-24 02:07:00,718 DEBUG FtpConsumer                    - Unsupported type of FTPFile: user        24576 21/08/07 17:19:28 *FILE      INVOKE (not a file or directory). It is skipped.

                   

                  2009-04-24 02:07:00,718 DEBUG FtpConsumer                    - Unsupported type of FTPFile: user      3854336 21/08/07 17:19:29 *FILE      JUSRC (not a file or directory). It is skipped.

                   

                  2009-04-24 02:07:00,718 DEBUG FtpConsumer                    - Unsupported type of FTPFile: user     10514432 21/03/09 19:54:27 *FILE      MIEADM60 (not a file or directory). It is skipped.

                   

                  ...

                   

                  ...

                   

                  ...

                   

                   

                   

                  I also, ran the commons FTPClient with out specifying a configuration and passing in the iSeries IFS directory e.g. "/M3BE/env/DEVE/MvxFileTransfer/....."

                   

                   

                   

                  And it switched to ifs mode on the iSeries to give me the files I required.

                   

                   

                   

                  It appears the FTPClient doesn't do this when running from inside fuse / camel. 

                   

                  Could this be a bug?

                   

                  All help much appreciated.

                   

                  Cheers

                   

                  Mark

                  • 6. Re: FTPing a file from iSeries IFS
                    Claus Ibsen Master

                    The code in FTPConsumer is:

                            client.changeWorkingDirectory(dir);

                            for (FTPFile ftpFile : client.listFiles()) {

                                if (ftpFile.isFile()) {

                                    pollFile(ftpFile);

                                } else if (ftpFile.isDirectory()) {

                                    if (isRecursive()) {

                                        pollDirectory(getFullFileName(ftpFile));

                                    }

                                } else {

                                    log.debug("Unsupported type of FTPFile: " + ftpFile + " (not a file or directory). It is skipped.");

                                }

                            }

                     

                     

                    The problem is that the FTP client API returns false to the file whether its a directory or a file. I guess the FTP client API doesnt fully understand the AS/400.

                     

                    If I am mistaking there might be some interface for directory listening parsing that can be implemented to cater for this, to detect and parse the AS/400 listenings.

                     

                    You said that you have some code working. Can you show the code you have that works? It will help us to understand and maybe implement a fix in Camel.

                    • 7. Re: FTPing a file from iSeries IFS
                      Gert Vanthienen Novice

                      L.S.,

                       

                      Could you check the path for your IFS file?  I did this a few times with our ServiceMix FTP endpoint and if I recall correctly, if you have the path wrong it will go to some library in your library list, but other than that we did not need to anything additional to get it working.

                       

                      E.g. you have this /root/env/DEVE in the FTP URL which I guess corresponds to the Windows UNC
                      SystemI\root\env\DEVE

                       

                      However, with that UNC path, the path in the IFS for the same location would be /env/DEVE so the FTP URL should read ftp://user:pass@system/env/DEVE.

                       

                      For the jt400 component, it only supports *DTAQ objects right now but it shouldn't be that hard to add support for IFS files.  Feel free to raise a JIRA if you would like to see this functionality being added...

                       

                      Regards,

                       

                      Gert

                      • 8. Re: FTPing a file from iSeries IFS
                        Mark Richards Newbie

                        Hi Gert,

                         

                        I have managed to get the ftp component working

                         

                        The issue was with the filename part of the uri.  To go to the IFS it seems you are required to give the path as

                        '/M3BE/env/DEVE/MvxFileTransfer/Toll_Priority/Manifest'

                         

                        The important part is the first '/' at the beginning of the filename.

                         

                        I'm not sure how the first '/' after the host part of the uri is used (in know I could go through the source....) if it is only used to split the uri at host and file.

                         

                        The following works for connecting to the iseries and reading directly from the  ifs at least,

                         

                        uri="ftp://user@host//M3BE/env/DEVE/MvxFileTransfer/Toll_Priority/Manifest?password=password"

                         

                        Not sure how this would work if connecting a unix box as I don't have one.

                         

                        Would it be better to have an explicit parameter for file name?

                         

                        Thanks for all the help, seems like a user error or possibly a documentation issue.

                         

                        Cheers

                        Mark