IBM Support

Passing more data to the Impact Webservice Listener 7.1

Technical Blog Post


Abstract

Passing more data to the Impact Webservice Listener 7.1

Body

 

The Impact Webservices Listener allows an external application to make a request to run a policy and pass parameters to that policy. 

 

There is an example java program supplied with Impact and information in the docs to describe how to use it to run a policy and pass a parameter to that policy.  The elements included with Impact can be found in the directory: 

 

    $IMPACT_HOME/integrations/web-service-listener

 

There you will find a README file which contains details of how to run the example client program.

 

However, it is not clear in the README, or in the docs, how to pass multiple parameters to the policy. 

 

In practice, the parameter passed to the policy is an Impact Object – essentially an array – so to pass multiple parameters to the policy, you just need to pass multiple elements in the array.  Here is an example of the steps to take to convert the example java client to pass multiple parameters (in this case 4), these steps assume you have already setup and tested the example client (with 1 parameter), according to the README:

 

1. Edit WSTestDL.java to pass 4 parameter to the policy.

Change:

      WslPolicyUserParameter thisParam = new WslPolicyUserParameter();

      thisParam.setName("PARAM1");

      thisParam.setValue("VALUE1");

      thisParam.setFormat("String");

      wParams.add(thisParam);

to:

      WslPolicyUserParameter thisParam = new WslPolicyUserParameter();

      thisParam.setName("PARAM1");

      thisParam.setValue("VALUE1");

      thisParam.setFormat("String");

      wParams.add(thisParam);

 

      WslPolicyUserParameter nextParam = new WslPolicyUserParameter();

      nextParam.setName("PARAM2");

      nextParam.setValue("VALUE2");

      nextParam.setFormat("String");

      wParams.add(nextParam);

 

      WslPolicyUserParameter param3 = new WslPolicyUserParameter();

      param3.setName("PARAM3");

      param3.setValue("VALUE3");

      param3.setFormat("String");

      wParams.add(param3);

 

      WslPolicyUserParameter param4 = new WslPolicyUserParameter();

      param4.setName("PARAM4");

      param4.setValue("VALUE4");

      param4.setFormat("String");

      wParams.add(param4);

 

2. Compile it into a WSTestDL.class file

cd $IMPACT_HOME/integrations/web-service-listener

export CLASSPATH=$CLASSPATH:.: $IMPACT_HOME/integrations/web-service-listener/lib/impact-web-service-listener.jar

$IMPACT_HOME/sdk/bin/javac WSTestDL.java

 

3. Then replace the file in the sample.client.jar file.

$IMPACT_HOME/sdk/bin/jar -uvf lib/sample-client.jar WSTestDL.class

 

4. Edit the policy WSListenerTestPolicy.ipl in the Impact GUI to print the 4 parameters:

Change:

      log("PARAM1= " + PARAM1);

To

      log("PARAM1 = " + PARAM1);

      log("PARAM2 = " + PARAM2);

      log("PARAM3 = " + PARAM3);

      log("PARAM4 = " + PARAM4);

 

5. Run the test program using the script:  test_wslistener.sh  as described in the README file and the docs.

 

I hope this proves useful.

 

[{"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Product":{"code":"","label":""},"Component":"","Platform":[{"code":"","label":""}],"Version":"","Edition":"","Line of Business":{"code":"","label":""}}]

UID

ibm11081443