This tip assumes you have installed aXes with the default values. If this is not the case, please adjust with your settings.
1) Make sure the IBMi Services (JSM) features are configured properly. For this check the following.
a) Make sure the subsystem AXES410JSM is running on your IBMi. Check WRKACTJOB for AXES410JSM
b) Make sure the IBMi Services (JSM) features is working by using the data explorer feature on the axes homepage.
If all is well configured you should see the login screen below. The login page for Data Explorer. If you get any messages, there is problem and this needs to be fixed first.
2) Navigate to your IFS folder IFS://axes410jsm/jsm/instance/system and open the file httpd.xml
a) Check the port under which the services are running. For this check around line 20 for <listen port=XXXX ...
b) Check that the services are working correctly by using the IBMi services port above http://yourserver:port.
c) Back to you httpd.xml file. Locate the the following property LongReach around line 215. Add the line under remote service activation to allow XSS:
<parameter name="service.origin" value="*"/>
d) Make sure the section All non-public users is uncommented as shown below. That is no <!-- -->. Note the value of the base folder (highlighted in yellow.
In our case the base folder is located at /longreach/user/{NAME}. Hence if you login to your server with USER1 the base folder will be at /longreach/user/USER1. You can change this folder as you wish.
e) Restart the SBS AXES410JSM on the IBMi.
3) We can now start designing our axes project to use this functionality.
a) Create a new project in aXes 410. Login to your IBMi using you project in the aXes developer tools.
b) First step is to add a file input field which will allow the selection of a files from the local computer. For this add a Multitype Input Box.
c) Set the following properties for the Multitype Input box (in yellow) d) Now drag and drop a Push Button. Set the following script in the onClick event. Call you button "put file"
Code: Select all
//add this to load the necessary JS library. Note user the IBMi services port and your server address. In our case it is LANSA14:8413
$.getScript("http://lansa14.syd.lansa.com.au:8413/axes/lui-encrypt-min.js");
$.getScript("http://lansa14.syd.lansa.com.au:8413/axes/lui-connector-min.js");
// the host JSON variable is used to define the server to which the request is going to. Use your server name with the IBMi services port again.
// Also fille in the IBMi Username allowed to access the server.
var m_host = { endpoint:"http://lansa14.syd.lansa.com.au:8413/service/longreach.jsp", profile:"ADMDEV", password:"xxxxx" } ;
putFile();
function putFile ()
{
//this is the call back function after the JSm call has returned.
function callback ( response )
{
console.timeEnd ( "put file" ) ;
alert ( JSON.stringify ( response ) ) ;
}
try
{
console.time ( "put file" ) ;
// This is where you get the data from your file input. GETFILES is an aXes API which returns the files from the
// Mutitype Input Box File selection as an array. We only use the first file at position 0.
var file_array = GETFILES( 'id-file1' );
var file = file_array[0];
if ( !file )
{
alert ( "Choose a file" ) ;
return ;
}
// Read file asynchronous
var reader = new FileReader() ;
reader.onloadend = function ( event )
{
if ( !reader.result ) // ArrayBuffer
{
alert ( "No read file result" ) ;
return ;
}
console.log ( "reader result length " + reader.result.byteLength ) ;
if ( reader.result.byteLength > 1000000 )
{
}
/*
Note: the reader.result will be encrypted, because Uint8Array uses the underlying ArrayBuffer.
*/
// Using asynchronous callback mode the file is sent to the server. Note the user of {BASE} define in the httpd.xml file
LUICONNECTOR.putFile ( m_host, { path:"{BASE}/docs", name:file.name }, callback, new Uint8Array( reader.result, 0, reader.result.byteLength ) ) ;
};
reader.readAsArrayBuffer( file ) ;
}
catch ( e )
{
alert ( "putFile exception " + e ) ;
}
}
4) Try your code.
a) Save your customisations and reload your project.
b) Pick a file on your computer
c) Click the put file button. You should see the following.
d) Open your IBMi and navigate to your {BASE} folder
END