What is the correct syntax for defining integration service output with a post processor

We are implementing an integration service of type OpenAPI (Swagger)

We implemented a Javascript post-processor with the following code:

function postProcess() {
var newOutputParam = new com.hcl.voltmx.middleware.dataobject.Param();
newOutputParam.setName('initialsAvailable');
newOutputParam.setValue(true);
result.setParam(newOutputParam);

}
postProcess();

As expected by testing the service the output of the post-processor is:

{
    "PostProcessor": {
        "Result": {
            "opstatus": 0,
            "initialsAvailable": "true",
            "Records": [],
            "httpStatusCode": 200
        }
    }
}

Now we want to define our own output for the service but we cannot get to build a working mapping.

If we use the following:

We don't get the initialsAvailable value in the response


If we use the alternate below:

We get an error in the log:

  1. {
  2. "Performance (in ms)": {
  3. "BACKEND_REQUEST": 546,
  4. "PRE_PROCESSOR": 23,
  5. "POST_PROCESSOR": 5,
  6. "contype": "OpenAPIAdapter",
  7. "REQUEST_MAPPER": 0
  8. },
  9. "Logs": [
  10. "[server.console][ERROR][2025-01-27T18:43:33.506+01:00]:[63e73740-c11f-4c6c-968f-6103134867e9]:[]:[]:[http-nio-8080-exec-148]:[ALERT.com.konylabs.middleware.connectors.json.JsonPathEngineImpl:error:93]:uuid=\"07026da95753426f9287b03144f382c1\",dim=\"A\",level=\"ERROR\",comp=\"TEMN-QF-Server Console-com.konylabs.middleware.connectors.json.JsonPathEngineImpl\",cn=\"com.konylabs.middleware.connectors.json.JsonPathEngineImpl:readPathFromDocumentContext:255\",\"QF\":TL=\"Log\",msg=\"No record found in the given path: No results for path: $['initialsAvailable']\""
  11. ]
  12. }

We are definetely doing something wrong but we have not found valid end-to-end examples that would allow us to achieve the result we need.

We need to use the boolean value in output to perform validations in an HCL Leap application so the output data type MUST be a boolean property. A string or value in an array would not work.

Hi Daniele, try using result.addParam() and use the alternate approach to your Output parameters. I believe the error is from trying to use result.setParam().

Cheers,
Gunndarr

I tried your suggestion but it is not changing the behaviour.

Replacing result.setParam() with result.addParam() but the outcome is not chaning.

My biggest problem is I am not finding good documentation on how the "output" of an integration service can be customized.

Hi Daniele, you are getting that error because the path you configured ($.initialsAvailable) does not exist in the output of the service from the backend. Please check that. If this parameter does not come from backend but you want to include it in the final output of the result, you can add it in the post-processor the way you already tried. Not sure what you mean by working map. Please explain so we can guide you further.

I confirm that initialsAvailable does not exist in the backend service.

My expectation is that by adding the parameter in my postProcessor I can then reference it in the output.

Let me express my question:

  1. Can a Swagger (Open API) integration service have a return schema that is different from the one I am consuming ? (my expectations is that this is possible)
  2. Can I use the output configuration to customize my output schema ? (and I see this is possible)
  3. How can I configure output to espose a new parameter that was not in the original output schema and that I added in my post-processo using the code I posted above ?

I can also add that I've not been able to find a coherent or complete reference of the javascript objects I should be able to use in the context of a postProcessor.

Samples offer a mix of resultToJSON and object bases approach but I cannot figure out the complete architecture of:

  • What should a post processor contain
  • Which objects explicitly exist
  • How do I manipulate a resultToJSON object and how I "commit" my changes to the actual service response
  • How do I manipulate the response using objects (and when I should use Reponse vs Result object)

What is difficutl is to set my expectations as I struggle finding documentation.

  1. Can a Swagger (Open API) integration service have a return schema that is different from the one I am consuming ? (my expectations is that this is possible) ==> Yes, possible
  2. Can I use the output configuration to customize my output schema ? (and I see this is possible) ==> Yes
  3. How can I configure output to espose a new parameter that was not in the original output schema and that I added in my post-processo using the code I posted above ? ==> By adding the required parameters/datasets/records in the post-processor. I see that you already successfully added a parameter in the post-processor.

Please refer to the documentation at the link: https://help.hcl-software.com/voltmx/v9.2/Foundry/voltmx_foundry_user_guide/Content/JS_Pre-Post_Samples.html

Here is some sample code that might help you. It demonstrates how to add Params, Records and DataSets to Result

function addToResult() {
//add creditScoreAvailable Param to Result
var creditAvailableParam = new com.hcl.voltmx.middleware.dataobject.Param();
creditAvailableParam.setName('creditScoreAvailable');
creditAvailableParam.setValue(true);
result.setParam(creditAvailableParam);

// add creditScore Param to Result
var lastdigit = request.getParameter("SSN");
var id = request.getParameter("customer_id");
var creditScoreParam = new com.hcl.voltmx.middleware.dataobject.Param();
creditScoreParam.setName('creditScore');
creditScoreParam.setValue(lastdigit.slice(-1) * 100 + Number(id));
result.setParam(creditScoreParam);

// add userName Record with firstName, lastName Params to Result
var userNameRecord = new com.hcl.voltmx.middleware.dataobject.Record();
userNameRecord.setId('userName')
var firstNameParam = new com.hcl.voltmx.middleware.dataobject.Param();
firstNameParam.setName('firstName');
firstNameParam.setValue('Padma');
userNameRecord.addParam(firstNameParam);
var lastNameParam = new com.hcl.voltmx.middleware.dataobject.Param();
lastNameParam.setName('lastName');
lastNameParam.setValue('Ramaraju');
userNameRecord.addParam(lastNameParam);
result.addRecord(userNameRecord);

// add creditSources Dataset to Result
var creditSourcesDataSet = new com.hcl.voltmx.middleware.dataobject.Dataset();
creditSourcesDataSet.setId('creditSources');
var source1Record = new com.hcl.voltmx.middleware.dataobject.Record();
var creditSource1Param = new com.hcl.voltmx.middleware.dataobject.Param();
creditSource1Param.setName('source');
creditSource1Param.setValue('Equifax');
source1Record.addParam(creditSource1Param);
creditSourcesDataSet.addRecord(source1Record);
var source2Record = new com.hcl.voltmx.middleware.dataobject.Record();
var creditSource2Param = new com.hcl.voltmx.middleware.dataobject.Param();
creditSource2Param.setName('source');
creditSource2Param.setValue('Experian');
source2Record.addParam(creditSource2Param);
creditSourcesDataSet.addRecord(source2Record);
var resDataSetsList = new java.util.ArrayList();
resDataSetsList.add(creditSourcesDataSet);
result.setDataSets(resDataSetsList);
}
addToResult();
The resulting output is as below:

{
"creditScore": "945",
"opstatus": 0,
"userName": {
"firstName": "Padma",
"lastName": "Ramaraju"
},
"creditScoreAvailable": "true",
"httpStatusCode": 200,
"creditSources": [
{
"source": "Equifax"
},
{
"source": "Experian"
}
]
}