KITE enables you to create Application Perspective scripts that include SOAP or RESTful Web API requests, also sometimes called Web services.
The KITE wizards help you quickly create an advanced script that provides the following advantages:
- Generates well-formed requests for each type of service.
- Handles basic error checking.
- Parses results and saves them in variables for use in subsequent actions in the transaction.
- Parses SOAP WSDL files into valid API calls.
Results of Web services requests are stored automatically in the Advanced Scripting Log. Thus errors are easily investigated and complex scripts can be created using results from one Web services query in subsequent script actions.
The provider of the Web service you are accessing should provide documentation of the service so that you can provide any needed information to complete the Web service request.
To create a new Web services script:
Select Record > Create Web Service Script.
From the drop-down, select the type of Web service script you want to create, SOAP or REST.
Depending on the type of Web service script you want to create, a different wizard interface is displayed. These are described below.
You can also add Web services request actions to existing scripts by selecting the top (script) level of the existing script, right-clicking, and selecting Add new Web Services API Action, then selecting SOAP or REST as the type of Web Service action.
SOAP web services
To create a valid SOAP Web services request you first need a valid WSDL file from the provider of Web service. The WSDL is a standardized XML file that defines the specific data the service can provide and how requests must be made. The WSDL file should be retrieved and stored locally.
After you select SOAP as the Web service type, a dialog is displayed where you specify the location of the WSDL file.
KITE parses the WSDL file and displays the methods that can be retrieved.
When you select one of the methods, a dialog is displayed with the method's parameters and empty fields where you enter the data required for that method.
You should consult the documentation for the Web service you are using to learn the required format for values you enter.
RESTful web services
To create a script or script action that includes RESTful Web services requests you need to provide a URL and typically must specify one or more parameters. The Web service should provide documentation describing the format and content required for each parameter.
The KITE Web Services window for RESTful services has several controls that allow you to choose:
- Whether to use HTTP Post, Get, Advanced Post, Put, or Delete. Get is the most common method.
- Which type of encoding to use for Post
- How the results will be formatted (JSON, XML, or Unstructured). JSON is most commonly used.
You can also enter any headers you want to include in the request.
Viewing results of web services actions
When you run a script that includes actions with Web services requests you can check the results by viewing the HTTP Payload for that action. Right-click the action in the Transaction Performance Details panel and select View HTTP Payload.
The request and response payloads are displayed.
Using the advanced scripting log
The Advanced Scripting Log captures variables from the Web services response. These variables can be used in subsequent actions of the script.
For example, a SOAP web service has a method with parameter username, and the username 'Ralph' is entered as the value.
When the script is run, in the Advanced Scripting Log we can see that the username Ralph has been stored in [GetUserResponse.GetUserResult.Username];
We can now add a SOAP action to the script that uses [GetUserResponse.GetUserResult.Username] as a value for parameter 'name':
When the script is run now, the SOAP web service uses the value stored in [GetUserResponse.GetUserResult.Username] in the [HelloToResponse.HelloToResult] variable.
You can use the HTTP Payload view (showing requests and responses), as well as the script log to see what results came back from your request. The Web API may generate its own errors, and those will be displayed in addition to any regular HTTP error codes when the script is run.