In this post I will be going through how to use Impact Web Services with a real example showing how to create an impact policy that uses Web Services to connect and retrieve information from an external system. To begin we need a WSDL file. Here is a sample WSDL file for getting a weather forecast: http://www.webservicex.net/weatherforecast.asmx?wsdl
Creating the Policy
Here are the steps to create a policy that uses the above WSDL file and retrieve the weather information.
In Impact 5.1.1, launch by clicking on Web Services wizard.
In Impact 6.1, in the TIP URL click on the System Configuration->Event Automation-> Policies-> drop-down menu of the Create New Policy->Use Wizard->Web Services
Name your policy and click “Next”.
Specify the URL for the WSDL file or if it is saved on your local disk then specify the path on the local disk
Select the compiled jar file if the WSDL is already compiled or give the name to the jar file and Impact will compile and create the Jar file. To create the Jar file for the given WSDL in advance use the following command (creates the “.jar” file in $IMPACT_HOME/wslib/):
$IMPACT_HOME/bin/nci_compilewsdl <wsdl URL>
Once you provide the Jar file and the WSDL location, Impact compiles the WSDL file and reads all the classes, methods available in the WSDL/jar file. Select which method or function you want your policy to use to request the data. In this Example, the weather WSDL file has two different methods – GetWeatherByZipCode and GetWeatherByPlaceName. We’ll use the zip code method.
The method we selected needs an input parameter i.e. we need to provide the Zip code for which we are requesting weather info.
Impact automatically reads the End point URL from the WSDL file (shown in the picture with an “.asmx” extension).
The above steps will create a policy as shown below and then you can modify the policy as per your needs!
Usage
From the above web service call, we get the weather information for the given zip code (the Classof() function determines the type of information returned if it is String type or Object type).
If you just want to extract a particular attribute from the weather forecast, here is the example on retrieving temperature from the weather information retrieved:
I will be adding more examples on Web Services and how to extract the data from complicated WSDL files in the upcoming posts.