Using Session Object In Script

Session object is activated when user logs in to start a session. You can access to various methods and properties of session object in scripts. Use keyword of "session" as follow.

1.Operating Session Properties
2.Operating Tables
3.Operating Files
4.Operating System Control Tables
5.Calculating Date and Time
6.Calling Functions
7.Controling Progress Bar
8.Controling Dialogs
9.Operating Web Services

Operating Session Properties
session.databaseName - Database name to be connected
session.databaseUser - Database user name
session.databasePassword - Database password
session.fileFolder - Folder of the definition file of thes system
session.fileName - Name(with path) of the definition file of this system
session.imageFileFolder - Image file folder of this system
session.logFileFolder - Log file folder of this system
session.outputFolder - output folder of this system
session.adminEmail - Email address of the administrator of this system
session.sessionID - Session ID
session.userEmployeeNo - Employee number of this user
session.userEmailAddress - Email address of this user
session.userID - User ID of this user
session.userName - User name of this user
session.getAttribute(String ID) - Method to get a session attribute by ID
session.setAttribute(String ID, String value) - Method to set a session attribute usually used in Log-in Script
session.getFunctionName(String ID) - Method to get a function name by its ID
session.subDBListSize - Count of sub-database definned
session.getSubDBName(int index) - Method to get sub-database name by index
session.getSubDBUser(int index) - Method to get sub-database user by index
session.getSubDBPassword(int index) - Method to get sub-database password by index
session.getSystemProperty(String ID) - Method to get JVM system information by using System.getProperty(ID).

Operating Tables
session.compressTable(String tableID) - Method to compress tables. You can use generic expression using *. Note that the method has no meanings for some of DBMSs.
session.copyTableRecords(String copiedFromTable, String copiedToTable, String type, int count, boolean isToCommitEachTime) - Method to copy records of the copiedFromTable to the copiedToTable. NOT-NULL fields on copiedFromTable must be defined as identical on the copiedToTable. Options of process type(type) are REPLACE or ADD or MERGE. If specified as REPLACE, copiedToTable is cleared(and compressed) before copying. In case of ADD, all records will be copied simply(all process will be canceled if key duplication occurs). In case of MERGE, records will be updated or inserted according to unique key constraints. You can also specify count of records to be copied(if omitted, all are processed). If isToCommitEachTime is omitted, it will be commited record by record. Note that you need to commit explicitly if false is specified. Method returns number of records processed if succeeded and returns -1 if failed.
session.createTableOperator(String sql) - Method to get TableOperator for a specified SQL(Refer to the same method of Function Object for details). Note that as this method is provided especially for Log-in Script, its operation is not recorded in function log.
session.createTableOperator(String operation, String tableID) - Method to get TableOperator for a specified table(Refer to the same method of Function Object for details). Note that as this method is provided especially for Log-in Script, its operation is not recorded in function log.
session.commit() - Method to commit transactions in Log-in Script.
session.decodeBase64StringToByteArray(String value) - Method to decode string in Base64 format into bytea(byte array).
session.encodeByteArrayToBase64String(byte[] byteArray) - Method to encode bytea(byte array) into string in Base64 format.
session.getTableName(String tableID) - Method to get table name with its ID.
session.getFieldName(String tableID, String fieldID) - Method to get field name with table ID and field ID.
session.getFieldType(String tableID, String fieldID) - Method to get field data type with table ID and field ID.
session.getFieldSize(String tableID, String fieldID) - Method to get field size(integer size for decimal type) with table ID and field ID.
session.getFieldDecimal(String tableID, String fieldID) - Method to get field deimal size with table ID and field ID.

Operating Files
session.showDialogToChooseFile(String fileExtention, String directory, String defaultFile) - Method to show a dialog to choose the file processed. Use comma to separate multiple values of fileExtention. You can specify initial directory on the dialog like C:\\Folder1\\Folder2 or <CURRENT>\\Folder3. If you put '' as directory or omit one, current directory is set as initial directory. You can omit defaultFile.
session.copyFile(String originalName, String newName) - Method to copy files. Original file must exists whereas if new file does not exist, it will be created. If successed, it returns true.
session.existsFile(String fileName) - Method to return true if the file specified exists.
session.deleteFile(String fileName) - Method to delete the file specified(with path name). If deleted it returns true.
session.renameFile(String currentName, String newName) - Method to change name or path of the file specified. It returns true if processing succeeded.
session.createExcelFileOperator(String fileName)
Method to get ExcelFileOperator for an existing Excel file. Available methods of the object are as follow.
-ExcelFileOperator#cloneSheet(int sheetIndex)
Method to copy the specific sheet and add as the last sheet of the book.
-ExcelFileOperator#setSheetNameAt(int sheetIndex, string value)
Method to name the specific sheet. Note that some charactors(/\?*[]) should not included.
-ExcelFileOperator#getLastRowIndex(int sheetIndex)
Method to get an index of the last sheet of the book.
-ExcelFileOperator#getValueAt(int sheetIndex, int rowIndex, int columnIndex)
Method to get value of the cell specified with indexes. Note that indexed start from 0.
-ExcelFileOperator#setValueAt(int sheetIndex, int rowIndex, int columnIndex, Object value)
Method to set value at the specified cell. If operation succeeded, it returs true. If the cell is date formated, the value should be a string value like '2001/01/01' or '2001-01-01' or '20010101'.
-ExcelFileOperator#removeRowAt(int sheetIndex, int rowIndex)
Method to clear data and config at the specific row.
-ExcelFileOperator#removeRowsBetween(int sheetIndex, int rowIndexFrom, int rowIndexThru)
Method to clear data and config between the specific row numbers.
-ExcelFileOperator#commit()
Method to commit changes of the file. If succeeded it returns true.
//////////
//Example//
//////////
isOkay = session.copyFile('C:\\Test\\Book1.xlsx', 'C:\\Test\\Book2.xlsx');
if (isOkay) {
  operator = session.createExcelFileOperator('C:\\Test\\Book2.xlsx');
  operator.setValueAt(0,1,0, 12345); //Numeric Cell at A2
  operator.setValueAt(0,1,1, '2016-12-31'); //Date Cell at B2
  operator.setValueAt(0,1,2, 'New string value'); //String Cell at C2
  operator.commit();
  session.browseFile('C:\\Test\\Book2.xlsx'); //Launching Excel
} else {
  showMessage('Failed copying file');
}
session.createTextFileOperator(String operation, String fileName, String separator, String charset) - Method to get TextFileOperator for the text file specified. Set 'Read' or 'Write' to operation and ','(comma) or '\t'(tab) or ''(no separator) to separator and 'UTF-8' or 'UTF-16' or 'EUC-JP' or 'Shift_JIS' or 'ISO-2022-JP' to charset. If charset is omitted, it represents automatic determination for 'Read' operation and UTF-8 for 'Write' operation. Available methods of the object are as follow.
-TextFileOperator#getValueAt(int index)
Method for 'Read' operation to get value of the column read at the index(the first is 0). Blank will be returned if the column at the index does not exist.
-TextFileOperator#getColumnCount()
Method for 'Read' operation to get count of columns read.
-TextFileOperator#getRowIndex()
Method for 'Read' operation to get index(the first is 0) of the row where cursor placed.
-TextFileOperator#next()
Method for 'Read' operation to put cursor at the next row. If the next row exists, it returns true.
-TextFileOperator#previous()
Method for 'Read' operation to put cursor at the previous row. If the previous row exists, it returns true.
-TextFileOperator#addValue(Object value)
Method for 'Write' operation to add value of the next column to the array. It returns index of the column added.
-TextFileOperator#addRow()
Method for 'Write' operation to add a row with the column values array. It returns index of the row added and the array is cleared then. Note that rows are not written until executed.
-TextFileOperator#execute()
Method to execute Read/Write operation to return count of rows processed. This will be implicitly executed in the first next() operation.
-TextFileOperator#resetCursor()
Method to reset cursor position. Note that next() is required to get column values.

Operating System Control Tables
session.getAnnualExchangeRate(String currency, int fYear, String type) - Method to get annual rate in float for the specific currency and fiscal year. Specify 'TTB' or 'TTM' or 'TTS' for type. If the system currency is requested it always returns 1.000.
session.getMonthlyExchangeRate(String currency, int fYear, int mSeq, String type) - Method to get monthly rate in float for the specific currency and fiscal year-month. Specify 'TTB' or 'TTM' or 'TTS' for type. If the system currency is requested it always returns 1.000.
session.getMonthlyExchangeRate(String currency, String date, String type) - Method to get annual rate in float for the specific currency and date. Specify 'TTB' or 'TTM' or 'TTS' for type. If the system currency is requested it always returns 1.000.
session.getNextNumber(String ID) - Method to get next auto-number with number ID specified.
session.setNextNumber(String ID, String value) - Method to update next auto-number with number ID and value specified. If target record is not found, warning message is shown.
session.getSystemVariantFloat(String ID) - Method to get float value of the specific system variant with its ID.
session.getSystemVariantInteger(String ID) - Method to get integer value of the specific system variant with its ID.
session.getSystemVariantString(String ID) - Method to get string value of the specific system variant with key ID.
session.setSystemVariant(String ID, String value) - Method to set string value to the specific system variant with key ID. If it does not exists, it create a new definition as STRING.
session.getTaxAmount(String date, int amount) - Method to get tax rate for specific date and amount. Valid only in Japan.
session.getTaxAmount(String date, int amount, String kbKazei) - Method to get tax rate for specific date and amount and kazei-kubun. Valid only in Japan.
session.getUserVariantDescription(String ID, String value) - Method to get description of user variant specified with its ID and value,

Calculating Date and Time
session.getDaysBetweenDates(String dateFrom, String dateThru, int countType, String kbCalendar) - Method to get lead time days between dates specified. With countType 0, it returns row value. With countType 1, it counts days skipping off-days. With kbCalendar omitted it scans standard(00) calendar. Note that calendar table is read only once when session starts.
session.getMinutesBetweenTimes(String timeFrom, String timeThru) - Method to get lead time minuites between time(in format of hh:mm)
session.getOffsetDate(String date, int days, int countType, String kbCalendar) - Method to get date value(String, Format:yyyy-MM-dd) in days from the date specified. With countType 0, it returns row value. With countType 1, it counts days skipping off-days. With kbCalendar omitted it scans standard(00) calendar. In order to express returned value is string, code as follows.
TABLEID_FIELDID.value = session.getOffsetDate(...) + '';
session.getOffsetDateTime(String date, String time, int minutes int countType, String kbCalendar) - Method to get date-time value(String, Format:yyyy-MM-dd hh:mm) in minutes from the date-time specified.
session.formatDate(String date, String format) - Method to get formated date according to specified yyyy-MM-dd value. If format is omitted, session date-format is applied.
session.formatTime(String time) - Method to get time value in format of hh:mm with time value specified
session.getLastDateOfTheYearMonth(String yearMonth) - Method to get the last date of the specific year month.
session.getMonthsBetweenYearMonths(String yearMonthFrom, String yearMonthThru) - Method to get lead time months between year-months specified.
session.getOffsetYearMonth(String yearMonth, int months) - Method to get yearMonth value(String, Format:yyyyMM) in months from the year-month specified.
session.timeStamp - Current date-time(like 2001-12-31 12:34:56.789). In order to express returned value is string, code as follows.
TABLEID_FIELDID.value = session.timeStamp + '';
session.thisMonth - Current year-month(String, Format:yyyyMM). In order to express returned value is string, code as follows.
TABLEID_FIELDID.value = session.thisMonth + '';
session.today - Current date(String, Format:yyyy-MM-dd). In order to express returned value is string, code as follows.
TABLEID_FIELDID.value = session.today + '';
session.isOffDate(String date, String kbCalendar) - Method to check if specified date is off or not. It returns true if the date is off. Note that system calendar table contains only off dates. With kbCalendar omitted it scans standard(00) calendar. Note that calendar table is read only once when session starts.
session.isValidDate(String date) - Method to check if date value is valid or not. It returns true if it is valid.
session.isValidDateFormat(String date, String separator) - Method to check if date value with separators is valid or not. It returns true if it is valid.
session.isValidTime(String time, String format) - Method to check if time value in format specified is valid or not. It returns true if it is valid. Available format is 'HH:MM' or 'HH:MM:SS'. You can give 3 digit decimal for SS.
session.getFYearOfDate(String date) - Method to get the fiscal year of the date(or date-time) specified. The value is calculated according to system variants with key of FIRST_MONTH(*1) and LAST_DAY(*2).
session.getMSeqOfDate(String date) - Method to get year and month-sequence of the date(or date-time) specified. The value is calculated according to system variants with key of FIRST_MONTH(*1) and LAST_DAY(*2).
session.getErrorOfAccountDate(String date) - Method to check if the date(or date-time) is acceptable for account date. It refers to the system variant with key of ALLOWED_FISCAL_MONTH(*3).
session.getYearMonthOfFYearMSeq(String fYearMSeq) - Method to get year-month(yyyyMM) for specified year and month-sequence. The value is calculated according to system variants with key of FIRST_MONTH(*1) and LAST_DAY(*2).

*1.The first month of fiscal year. For example, 4 represents April. If not registered with the key in system variant table, its value is assumed to be 1.
*2.The last day of the fiscal year. 31 means the last day of each month. If not registered with the key in system variant table, its value is assumed to be 31.
*3.For example, if the value is 201611, it means the 11th month of the fiscal year of 2016 is the past limit one can input account data.

Calling Functions
session.executeProgram(String programName) - Method to call an external function(including a command) to return a message. Refer to Function Object for calling internal functions.
session.browseFile(String fileName) - Method to call a desktop program to browse a content of a file specified with the name.
session.editFile(String fileName) - Method to call a desktop program to edit a content of a file specified with the name.
session.sendMail(String addressFrom, String addressTo, String addressCc, String subject, String message, String fileName, String attachedName, String charset) - Method to send a mail specified by parameters(last three parameters are omittable). It uses SMTP server, port, user and password specified as system definitions. Refer to an example in Function Object.

Controlling Progress Bar
session.startProgress(String text, int max) - Method to setup and show progress bar on the current active form. The text is shown on the bar and max value is set as specified.
session.incrementProgress() - Method to add 1 to the current value of the progress bar. If value has come up to the max, the bar will be closed.
session.endProgress() - Method to close the bar.

Controlling Dialogs
session.getOptionDialog() - Method to get an object of OptionDialog. On the dialog users type arrow-key to choose option and Enter to execute or mouse-click the option to execute. Following is an example with codes.



var dialog = session.getOptionDialog();
dialog.addOption('Value of OPTION as 1'); // reply:0 //
dialog.addOption('Value of OPTION as 2'); // reply:1 //
dialog.addOption('Close'); // reply:2 //
dialog.setWidth(300);

var reply = dialog.request('Choose an Option');
if (reply == 0) {
   instance.parmMap.put('OPTION', '1');
   instance.callFunction('FNCTION1');
}
if (reply == 1) {
   instance.parmMap.put('OPTION', '2');
   instance.callFunction('FNCTION1');
}
if (reply == 2 || reply == -1) {
   instance.returnMap.put('RETURN_MESSAGE', '*Processing Canceled.');
}

session.getInputDialog() - Method to get an object of InputDialog. Methods available are as follow.
InputDialog#addField(String caption, String inputType, int area, String parmID) - Method to add a field to get Field object. InputType is either of ALPHA, ZEROFILL, KANJI, NUMERIC, DATE, LISTBOX, CHECKBOX, TEXTAREA. Area is either of 0(top), 1(center), -1(not visible). ParmID is omittable which is to link to the parameter mentioned later.
InputDialog#request(String title) - Method to show dialog with the title specified.
InputDialog#setMessage(String message) - Method to set the message on dialog.
InputDialog#setMessageHeight(int height) - Method to set height of message area explicitly(default is 55).
InputDialog#setWidth(int width) - Method to set width of dialog explicitly(default is 300). Width may be extended automatically according to the width of field added.

Methods for Field object gotten by addField(...) are as follow.
Field#setEditable(boolean editable) - Method to set if the field is editable or not.
Field#isEditable() - Method to get if the field is editable or not.
Field#getParmID() - Method to get ParmID.
Field#setSize(int digits) - Method to set field length valid for types of ALPHA, ZEROFILL, KANJI, NUMERIC.
Field#setDecimal(int decimals) - Method to set decimal length of NUMERIC field. Note that setSize(...) is to set length of integer for Numeric field.
Field#setValue(Object value) - Method to set value at the field.
Field#getValue() - Method to get field value.
Field#addItem(String externalValue, Object internalValue) - Method to add an item for LISTBOX fields. ExternalValue is how it is shown on the list. Use getValue() to get internalValue of selected item and use getItem() to get externalValue of selected item.
Field#getItemCount() - Method to get count of items in a LISTBOX field.
Field#setPrompter(String prompterID, String parmIDsPuttingFrom, String parmIDsPuttingInto, String parmIDsGettingFrom, String parmIDsGettingInto) - Method to set prompter for field type of ALPHA, ZEROFILL and NUMERIC. ParmIDs are separated by ';'.
Field#setFileChooser(String title, String fileExtentions, String initialDirectory) - Method to set file chooser for type of ALPHA field. File extentions are separated by ';'. If initial directory is omited, file path value specified by setValue() is set implicitly.
Field#setDirectoryChooser(String title, String initialDirectory) - Method to set file chooser for type of ALPHA field. If initial directory is omited, file path value specified by setValue() is set implicitly.
Field#setComment(String text) - Method to set comment at right side of the field.

Following is an example with codes. On the dialog users type tab-key to transfer focus and Enter or OK to execute.



// Dialog Definition //
var dialog = session.getInputDialog();
dialog.setMessage('*Specify settings for BOM explosion.');
dialog.setWidth(400);

// Item Number //
var nrItem = dialog.addField('Item Number', 'ALPHA', 0, 'NRITEM');
nrItem.setEditable(false);
nrItem.setSize(15);
nrItem.setValue(instance.parmMap.get('NRITEM'));

// Feature Option Code //
var cdFopt = dialog.addField('F/O Code', 'ALPHA', 0, 'CDFOPT');
cdFopt.setSize(10);
cdFopt.setPrompter('BF200', 'NRITEM;CDFOPT', 'NRITEM;CDFOPT', 'CDFOPT','CDFOPT');

// Target Date for Explosion //
var dtExplosion = dialog.addField('Target Date', 'DATE', 0);

// Unit Quantity //
var qtExplosion = dialog.addField('Unit Quantity', 'NUMERIC', 1);
qtExplosion.setValue(1);
qtExplosion.setSize(7);

// Explosion Type //
var kbExplosion = dialog.addField('Explosion Type', 'LISTBOX', 1);
kbExplosion.addItem('Single Level', '1');
kbExplosion.addItem('Structures', '2');
kbExplosion.addItem('Summary', '3');

// Pass-Thru //
var fgPassthru = dialog.addField('Pass-Thru', 'CHECKBOX', 1);
fgPassthru.setValue(true);

// Showing dialog to request answers //
var reply = dialog.request('Settings for BOM Explosion');
if (reply == 0) {
   if (fgPassthru.value == true) {
      ...
   } else {
      ...
   }
} else {
   instance.returnMap.put('RETURN_MESSAGE', '*Processing canceled.');
}


session.getCheckListDialog() - Method to get an object of CheckListDialog. Differs from OptionDialog is that you can check multiple options at the same time on CheckListDialog. It's useful as a prompter for filter criteria of function types XF100,110,300. Methods available are as follow.
CheckListDialog#addRow(String keyValue, String expression, boolean isSelected) - Method to add a row in dialog.
CheckListDialog#sortList(boolean isSotedAscend) - Method to sort rows according to expressions. if parameter ommitted, it will be sorted ascend. if false specified, it will be sorted descend.
CheckListDialog#setWidth(int width) - Method to set width of dialog.
CheckListDialog#request(String title) - Method to show dialog with the title specified.
CheckListDialog#setListSelected(String keyList) - Method to set specific rows selected with key values. Values are separated by ';'.
CheckListDialog#getListSelected() - Method to get list of key values selected on dialog. Values are separated by ';'.
CheckListDialog#isSelected(String KeyValue) - Method to get if a specific row with key value is selected or not.

Following is an example with codes. This function is defined as XF000 and it is linked as a prompter of criteria field of XF100,110,300 and checked values work as OR conditions. Exchange parameters for the prompter are all 'JT010.STORDER'.



// Dialog Definition //
var dialog = session.getCheckListDialog();
dialog.addRow('10', 'Opened');
dialog.addRow('20', 'Issued');
dialog.addRow('30', 'Dispatched');
dialog.addRow('40', 'Closed');
dialog.setListSelected(instance.parmMap.get('JT010.STORDER'));

// Display Dialog to Request Checking List //
var reply = dialog.request('Checking Order Status');
if (reply == 0) {
   instance.returnMap.put('JT010.STORDER', dialog.getListSelected());
}


Operating Web Services
session.getDigestedValue(String value, String algorithm, int expand, String saltValue)
Method to get digested value of the value specified according to the algorithm specified. Typically used to process password for vendor/customer to login EDI module. Available algorithms are MD5, SHA-1, SHA-256, SHA-384, SHA-512 etc.(Refer to java.security.MessageDigest). It returns blank value if algorithm specified is invalid. If last 2 parameters omitted, those values 1 and '' are applied respectedlly. If last 3 parameters omitted, "Hash Format" of the system will be appllied.
session.getRandomString(int length, String characters)
Method to get random string with specified length and characters. Used to reset password value.
session.requestWebService(String uri, String encoding)
Method to send GET-Request(*4) as uri specified to receive Response(*5). Encoding is omittable(default is UTF-8).
session.createWebServiceRequest(String uri, String encoding)
Method to get POST-Request object for the WEB-service-uri specified. Encoding is omittable(default is UTF-8). Available methods of Request object are as follow.
Request#setParameter(String name, String value) - Method to set value to the parameter specified by name.
Request#setHeader(String name, String value) - Method to set value to the header specified by name.
Request#execute() - Method to send POST-Request to receive Response(*5).
session.parseStringToGetXmlDocument(String data, String encoding)
Method to parse text data in XML format to get XML dokument. Encoding is omittable(default is UTF-8).
session.parseXmlDocumentToGetString(Document document)
Method to transform XML document to plain text. Useful for testing.
session.createXmlDocument(String name)
Method to get XML document which root tag is the name specified. Name is omittable.
session.createXmlNode(Document document, String name)
Method to add a node with the tag name specified to the XML document. Notice that even you can add a node but you can not put the node in specific position. You need to do like existingNode.appendChild(newNode) to put newNode as a child node of existingNode.
session.getXmlNode(Element node, String name)
Method to get XML node with the tag name specified from the node(or XML document). If multiple nodes exist with the tag name, the first node in position will be selected. Use method of node.getAttribute(name) to get attribute value of the node and node.setAttribute(name, value) to set value to the specific attribute of the node. And use node.setTextContent(value) to set text content value at the specific node.
session.getXmlNodeList(Element node, String name)
Method to get XML node list with the tag name specified from the node(or XML document). Use nodelist.get(index) to get specific node at the index of nodelist. And use nodelist.size() to get count of nodes on nodelist.
session.getXmlNodeContent(Element node, String name)
Method to get text content with the tag name specified from the node(or XML document).
session.createJsonObject(String text)
Method to create and get JSON object with text specified. Text value is omittable and it should be in JSON format which means it looks like {...}.
session.createJsonArray(String text)
Method to create and get JSON array with text specified. Text value should be in JSON array format which means it looks like [...].
session.getJsonArray(JsonObject object, String key)
Method to get a JSON array with the name of key.
session.getJsonObject(JsonObject object, String key)
Method to get a JSON object with key from specified JSON object. Use object.getString(key) to get string value of specific key from the object. Use object.getInt(key) to get integer value. And use object.put(key, value) to put value to specific key of the object.
session.getJsonObject(JsonArray array, int index)
Method to get a JSON object at the index of the JSON array.

*4.GET-request is coded in uri to be sent. And POST-request is created as an object to be sent. If you have multiple parameters for your request, you had better use POST-request.
*5.As response itself is a plain-text value, you need to parse it as XML document or JSON object to process.

Following is a sample coding. This is a script to communicate with web-service to get address by Japanese ZIP number. It send a GET request to receive response to parse it as XML document.

// Variants Definition //
var reply = 0;
var dialog = session.getInputDialog(); var reply;
var nrYubin = dialog.addField('ZIP Number', 'ALPHA', 0);
nrYubin.setSize(8);
var txJyusyo = dialog.addField('Address', 'ALPHA', 0);
txJyusyo.setSize(50);
txJyusyo.setEditable(false);
dialog.setMessage('Input ZIP number to get address. This is driven by the web-service zip.cgis.biz.');

// Show Dialog to Request //
for (;;) {
   reply = dialog.request('Using a WEB-Service');
   if (reply == 0) {
      var value = nrYubin.value.replace('-', '');
      var uri = 'http://zip.cgis.biz/xml/zip.php?zn=' + value;
      var response = session.requestWebService(uri);
      var document = session.parseStringToGetXmlDocument(response);
      var rootNode = session.getXmlNode(document, 'ZIP_result');
      var nodeList = session.getXmlNodeList(rootNode, 'value');
      if (nodeList == null || nodeList.size() < 7) {
         dialog.setMessage('ZIP Number is invalid.');
      } else {
         var stateText = nodeList.get(4).getAttribute('state');
         var cityText = nodeList.get(5).getAttribute('city');
         var addressText = nodeList.get(6).getAttribute('address');
         txJyusyo.value = stateText + ' ' + cityText + ' ' + addressText;
         dialog.setMessage('Address is successfully scanned.');
      }
   } else {
      break;
   }
}

Notice that this is a sample to use an existing web-service. Refer to Publishing WEB-Service to create your own web-services.
H O M E