When you have hundreds of responses for an operation within a
mockService it can be very difficult to search and modify them. This
dificulty increases with the number of people who are working on the
same project at the same time trying to edit these responses. Having the
responses in an easy editable CSV file is much convinient. To achieve
this goal we have found a solution which has been described below :
Here below is full script from the above screen
Step 1 : Update Mock Service
Update the mockService to validate the incoming request for conformity of the request. You can refer to topic "Soap Request Schema Validation : mock Services" to achieve this level.
Step 2 : Update Operation
Open the operation under mockService and put the script below under
Here below is full script from the above screen
The above script search for the requested data in the CSV file, if the
data is found and value for "returnCode" column is "0" in the CSV file
then it returns the "NominalResponse" otherwise returns the response
which is mentioned in the place of returnCode under the CSV file. If
both these case are failed then it returns "ResponseUnknown".
Put the below script (need to udpated for each webservice and each operation) in the "Script" tab of the "NominalResponse". This script fetch the corresponding data from the CSV file and put it in place of the context variables which are used in the response.
The above script has to be made common for all the common responses, if any special case response is required then add the special case in the CSV file and in the response list and update the scripts according to your needs.
Step 3 : Update the Response
The next step is to update the nominal response and parameterize the values with the actual results from the CSV file. Here a new search is made to the CSV file and corresponding data is fetched. Since we already know that the data exist in the CSV file hence no alternate is given, however you are free to improve this script as per your need.Put the below script (need to udpated for each webservice and each operation) in the "Script" tab of the "NominalResponse". This script fetch the corresponding data from the CSV file and put it in place of the context variables which are used in the response.
The above script has to be made common for all the common responses, if any special case response is required then add the special case in the CSV file and in the response list and update the scripts according to your needs.
No comments:
Post a Comment