Topics: |
How to: |
The Script object is available, which you can configure and add to flows that are constructed in iIT. The Script object uses the following iSM service type:
com.iwaysoftware.service.ScriptAgent
The Script object allows you to include complex document processing and routing instructions in your flow that are written in any scripting language that is supported by the Java Scripting API (for example, Jython). This enables your application to optimize some of the application processing into a script rather than a complex flow. As a result, you can also reuse identical logic across multiple systems.
To add the Script object to a flow, click and drag the Script object from the Components section of the Palette, as shown in the following image.
The new Script object is added to the workspace area, as shown in the following image.
The Script object is now in the flow between the Start and End objects, as shown in the following image.
How to: |
This example shows how a flow and service can be invoked using the Script object.
importPackage(com.ibi.edaqm); importPackage(com.iwaysoftware.iwscript); function execute() { var outDir = tools.getSpecialRegister("docOut"); params = tools.newParameters(); params.put("directory", outDir); // execute process processName = "hello_p1"; process = tools.getProcess(processName); processResponse = new XDDocument(); state = process.execute(ctx.getDocIn(), processResponse); if (state.indexOf('fail') == 0) { tools.info("Process flow '" + processName + "' not found"); } else { // write result of process to file params.put("pattern", "process.xml"); processToFile = tools.makeNewService("XDFileEmitAgent", params); processToFile.execute(processResponse, new XDDocument()); return "success"; } }
C:\Scripts\pflowobj.js
This flow must contain a Start object, Script object, and an End object.
Verify that a response is obtained in the destination as defined by the new application.
How to: |
This example shows how an iWay Transform component can be invoked using the Script object.
importPackage(com.ibi.edaqm); importPackage(com.iwaysoftware.iwscript); function execute() { transformResult = new XDDocument(); transform = tools.getTransform("Computer_Parts_Sales"); status = transform.execute(ctx.getDocIn(), transformResult); return XDAgent.EX_SUCCESS; }
C:\Scripts\transformobj.js
This flow must contain a Start object, Script object, and an End object.
<ism_home>\tools\transformer\samples\transform_projects\xml\XML_to_XML\Computer_Parts_Sales
<ism_home>\tools\transformer\samples\transform_projects\xml\XML_to_XML\Computer_Parts_Sales\input.xml
Verify that a response is obtained in the destination as defined by the new application.