Reflection Desktop (including Pro, and for IBM) 16.0 or higher
The Username and Password cannot be set as 5250 File Transfer Properties in Reflection .NET and sent programmatically in the VB.NET application like was possible in Reflection 14.x. Because the UserName and Password cannot be sent, full automation of a 5250 file transfer can not be accomplished and thus when writing a 5250 file transfer program, the user will have to manually enter the username and password for the file transfer. The following technical article provides a solution to this issue.
Option #1 - For the ft.AS400ReceiveFile() method, specify a file transfer .xto file that contains the local and remote file names along with the username and password to transfer the file. This maybe unacceptable to some users as they will have to create an .xto file for each file they wish to download, but maybe a solution to users with limited file names to be transferred.
Option #2 - Use VB.NET with the latest Reflection .NET interface and use a Reflection RD5X Host session and create 5250 file transfer "on-the-fly".
This example assumes user name is âUser01â and password is âPass01â.
1. In Reflection open an existing .RD5X host session file to the AS/400 / iSeries system or create a new host session with the appropriate connection information.
2. Open the Visual Basic Editor in the Reflection session.
3. Click on the Legacy section and expand it.
4. Click on the âSessionâ object.
5. Enter the following code in the right hand window of the VBA editor:
.UserName = "User01"
.SetEncryptedString rcPassword, "Pass01"
6. Click on the Run / Run Macro menu. The macro will run in less than a fraction of a second.
7. Verify in the Properties table on the lower left that the values of âUserNameâ and âPasswordâ got set with appropriate values.
8. Save and Exit the VBA Editor.
9. Save and Exit the RD5X file.
This .RD5X host session file will now contain the username and password specified above.
10. In the VB.NET file transfer application written using Visual Studio 2015 or higher, add the following code:
' Start a visible instance of Reflection Or get the instance running at the given channel name
Dim app As Application = MyReflection.CreateApplication("myWorkspace", True)
' Open an existing RD5X file which has the UserName and Password saved in legacy-Reflection section
Dim sessionPath As String = Environment.GetEnvironmentVariable("USERPROFILE") & "\Documents\Micro Focus\Reflection\as400.rd5x"
Dim terminal As IIbmTerminal = CType(app.CreateControl(sessionPath), IIbmTerminal)
' Create a View to make the session visible
Dim frame As UserInterface.IFrame = CType(app.GetObject("Frame"), UserInterface.IFrame)
' Perform 5250 File Transfer
Dim ft As IFileTransfer
ft = terminal.FileTransfer
ft.Xfr400LocalFile = Environ("USERPROFILE") & "\Documents\Micro Focus\Reflection\AS400File.txt"
ft.Xfr400RemoteFile = "User01/filetxt(filetxt)"
ft.Xfr400OutputDest = AS400OutputDestinationOption.File
ft.Xfr400ExistsAction = DefaultExistsActionOption.Overwrite
ft.Xfr400ShowProgress = True
Msgbox("File Transfer Host Return Code = " & Str(ft.XfrHostReturnCode))
When run, the VB.NET code above, which loads the .RD5X file where the username and password are already stored, the 5250 file transfer will run successfully with the Reflection Desktop .NET API.