Foundry Lab 02 - Hello Name Integration Service
Duration 15 Min
What you will learn
You'll learn how to create an integration with an input parameter, validate the input parameter and error or return a JSON object including a message element that says "Hello" to the username sent.
Prerequisites
- Lab 01 completed
Steps
helloName.vss
- For completeness, in
atlas.json
, add a second element to mainScripts called "helloName.vss". - Create a file "helloName.vss" in the src directory.
- Type "foundry" and accept the Foundry Boilerplate snippet.
-
Between the two comment blocks, enter the following code:
-
Save the file.
Success
Returns an error message if no username is entered. Otherwise, a message element with the value "Hello " + username is added to the result's JSON object.
Package for Foundry
- From the Command Palette, run "VoltScript: Package for Foundry".
- Enter the project directory, confirm atlas.json locations and continue with nothing entered for additional files to package.
Success
A file is created in the root of the project called "foundry-lab.1.0.0.zip". The zip name comprises the project name and the project version from the atlas.json.
Test with mock Foundry payload
Info
At this point, you would push the zip to Foundry. But Volt MX Go Foundry with VoltScript is not yet publicly available. You will need to test manually.
-
In helloworld.vss add a private function call
getMockData()
, returning a string.The function should look like this:
Private Function getMockData() Return |{ "projectDir": "ADD PROJECT DIRECTORY PATH HERE", "result": {}, "request": { "headers": { "content-length": "402138", "cookie": "JSESSIONID=0387B9D1BF9FA658D095713B75976EF8", "x-voltmx-authorization": "eyAidHlwIjogImp3dCIsICJhbGciOiAiUlMyNTYiIH0.eyAiX2VtYWlsIjogInBhdWxzdGVwaGVuLndpdGhlcnNAaGNsLmNvbSIsICJfdmVyIjogInYxLjEiLCAiaXNzIjogImh0dHA6Ly9sb2NhbGhvc3Q6ODA4MC9hdXRoU2VydmljZS9hY2NvdW50cyIsICJfc2NvcGUiOiAiZyIsICJfaXNzbWV0YSI6ICIvbWV0YWRhdGEvU053dmNOTy1ValJkSnFvQ0VYNW1NZz09IiwgIl9zZXNzaW9uX2lkIjogIjkwZWRkYzhjLWZjYzEtNGU4MC1iOTU2LTdiNGVhMTI2ZGQwZiIsICJfcHVpZCI6IDQ1MTYxOTQ4ODAxNzYsICJfaWRwIjogInVzZXJzdG9yZSIsICJleHAiOiAxNzExNDU2MTMxLCAiaWF0IjogMTcxMTQ1MjUzMSwgIl9zZXNzaW9uX3RpZCI6ICJhY2NvdW50cyIsICJfcHJvdl91c2VyaWQiOiAicGF1bHN0ZXBoZW4ud2l0aGVyc0BoY2wuY29tIiwgImp0aSI6ICJiMzE2OTdkYS00YjgwLTQxZDQtOWQ2Yi00MTY4YWIwNjRjMWUiLCAiX2FjcyI6ICJhY2NvdW50cyIgfQ.aZrLnTvl8noUTb_K7ulpNpYOADmx-CkecDH0C24vE-P9ZxiWQmyShdeto-RSu8rBlh5gzDNHqw2PwXcjXgByFLImroBpy7chbifHCWr5pBicBneCCcZWLE-6sVewTjwWQd__noNhYftki2dAwtv5oEx3d87NYV_RGikGpjkQk8c9MZpmPQAb3up2-hGSROAAlhmHwM3hRB7avofUMwMpWVDt0peYeTxr51qVIYjoG0U8i0-eb4Xg9ZaT1VgVEY4H5Yb-W_qdsxlJdk70pIZlQH_HiydwRSqqUe7AGEo6Tr45oeexTxbXiARV9p-dB4VlS0RSQp_wDvKsXFaLkoXuYA", "host": "localhost:8080", "connection": "Keep-Alive", "accept-encoding": "gzip,deflate", "x-voltmx-server-console": "ADMIN-PORTAL-LOGICAL-URL-CHANGE", "user-agent": "Apache-HttpClient/4.5.13 (Java/11.0.13)" }, "params": { "current_serviceID": "helloName", "current_appID": "foundry-lab-vs", "appID": "foundry-lab-vs", "eventObserverID": "helloName", "curent_apiVersion": "1.0", "serviceID": "helloName", "vsTestingContext": "true", "username": "John Doe" } }, "response": {}, "session": { "attributes": { "KCookie": [] }, "cookies": {} }, "serviceInputParams": { "username": "John Doe" } }| End Function
-
Replace
data = ctx.Context
withdata = getMockData()
. -
Run the script.
-
In
getMockData()
, remove the "username" JSON element inserviceInputParams
. -
Run the script.
Success
The code should print out the following JSON:
Warning
The "username" element appears twice, in request.params and serviceInputParams. It is the latter which is used for
getInputParam()
. The former is for params that are not explicitly mapped into the request input.
Info
Integration services can be created to interact with Domino. The process would be the same, using the same Foundry boilerplate snippet, but including KeepVSE. With an identity service, the Domino REST API JWT token will be automatically passed to the instantiated KeepServer
object. For integration testing, you will still need to call KeepServer.login(username, password)
. Apart from this, the code will be the same as any other use of KeepVSE.