Skip to content

Introduction

Easit ProcessRunner, or EPR for short, makes it possible to integrate Easit GO with your existing PowerShell scripts. EPR consist of a java application running in an instance of Apache Tomcat, installed as a Windows service.

Once started, EPR listens for incoming request using a REST service. When a request is received, the JSON body of the request is passed on as a argument to a script file with the same name as the value of "importHandlerIdentifier" in the body. We also send a base64 representation of the JSON body via stdin.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
    {
        "importHandlerIdentifier":"testService.ps1",
        "itemToImport":[
            {
                "property":[
                    {
                        "content":"123456",
                        "name":"requestId",
                        "rawValue":null
                    },{
                        "content":"aValue",
                        "name":"aProperty",
                        "rawValue":null
                    }
                ],
                "attachment":[],
                "id":"123456:2",
                "uid":"123456"
            }
        ],
        "genericRequestProperty":[
            {
                "content":"testService.ps1",
                "name":"identifier"
            },{
                "content":"MC0CFHnd2e81XFZezdFIHPj5i+A/6dbPAhUAkUKMTyjRZtJ7SZ6c/3KL0aeZKd4=",
                "name":"initializedByXmlExport"
            }
        ]
    }

To put in to context, the command executed by the java application, with the example above would be as shows below.

1
    C:\Users\administrator> pwsh.exe -File "Path/To/Scripts/scriptName.ps1"

To further exemplify this, our script scriptName.ps1 looks like this:

1
2
3
4
5
6
7
8
9
    [CmdletBinding()]
    param(
        [Parameter(Mandatory,Position=0)]
        [string]$Base64StringFromStdIn
    )
    $easitGOItem = Convert-EasitGOExportString -InputString $Base64StringFromStdIn
    # Write message and object to console
    "Received exported item $($easitGOItem.uid)"
    $easitGOItem

and will produce this output:

1
2
3
4
5
    Received exported item 123456

    requestId aProperty
    --------- --------
    123456    aValue

Once the script have completed, EPR will evaluate LASTEXITCODE. If LASTEXITCODE is anything else than 0 the java application will treat it as an error or failure.