Commands for Interacting w/ Web Services using wsCONNECT
You can read about the purpose of these powerful commands in this article.
The table(s) below lists the commands in the ascending alphabetic order within each category along with a brief description of the purpose behind the command. By clicking on the hyperlinked command name in the table(s) below, you can review more detailed information about a specific command that includes the syntax for you to follow when using the commands.
Please note that these commands (constructs) are supported within Worksoft SaaS application (Edit Test Script screen) only and NOT supported in QaSCRIBE test authoring tool.
Command | Purpose |
---|---|
wsAuthenticationType | This command is used to set authentication type for the service under test. At present only two types of authentication mode are supported i.e. Basic and Digest. This command is to be used only when the service under test is public facing. For services that are behind the firewall and for the runs wsCONNECT component is used, this command is ignored. |
wsBlockEnd | This command signifies the End of a Web service Block within a Test Script. Each wsBlockEnd must be accompanied by a matching wsBlockOpen that exists before it within the same Test Script. There can be more than one wsBlocks within a single Test Script. |
wsBlockOpen | This command signifies the beginning of a web service block within a Test Script. Each wsBlockOpen must be accompanied by a matching wsBlockEnd that exists after it within the same Test Script. There can be more than one web service blocks within a single Test Script. Web service blocks are referred to as wsBlocks for simplicity. |
wsExecuteRequest | This command is the main command that is responsible for getting the URL identified by a wsSetRequestURL, executed by the appropriate wsCONNECT Tunnel operating on one of your company's servers (If the service under test is public facing, then invoking of the service is done from within the run) For services behind the firewall,Worksoft SaaS does NOT call the service from/on its cloud but sends the information to the appropriate wsCONNECT on your end along with the request parameters and the payload. When wsCONNECT Tunnel receives this execution request from Worksoft SaaS, in the context of a test being executed within your domain, wsCONNECT reads from ws.json (that drives your wsCONNECT tunnel) the base URL, authentication credentials to trigger the service call. Since it may take some time for the wsCONNECT and/or your service to respond, Worksoft SaaS waits asynchronously for the service result to be sent back from wsCONNECT. When the service provides a response, wsCONNECT sends the result set back to Worksoft SaaS, and the test that is executing in Worksoft SaaS, that was waiting for the execution results, proceeds with the test execution. If the response does NOT go back to Worksoft SaaS within the maximum time allowed for a query (as specified explicitly by the use of wsSetRequestTimeOut command or implicitly applied with a default value if that command is not used), the test that in Worksoft SaaS that was waiting for the results of the service call, will automatically abort the test. |
wsGetResponseErrorFields | This command is used to read the error messages of the JSON response. This command works only with RESTful services and not with SOAP services. |
wsGetResponseHttpStatusCode | This command is used to set the HTTP response status code to the service under test. |
wsSetContext | This command is used to specify to Worksoft SaaS the "wsCONNECT tunnel" (that is operating within your company's firewall) that will service the triggering of services mentioned within the current wsBlock. As a security best practice, Worksoft SaaS does NOT need to know any more information (IP addresses, hostnames, usernames, passwords, etc) of the services (behind your company's applications (AUT) and behind your firewalls) beyond the alias name(s) you give to those web server. The " ws.json" file that drives the wsCONNECT tunnel (operating within your company's infrastructure) is where you can specify the all the above details and assign a ' ws alias name' which then you'd use safely in Worksoft SaaS. Since ws.json is on your company's network, Worksoft SaaS cannot access these settings. The "wsCONNECT Tunnel Name" is a name you give to your wsCONNECT Tunnel when you start the Tunnel. The name you give must be unique. |
wsSetPassword | This command is used to specify the password to be used for authentication in the service under test. This command is to be used only when the service under test is public facing. For services that are behind the firewall and for the runs wsCONNECT component is used, this command is ignored. |
wsSetProtocol | This command is used to identify the Protocol of the service under test. Keyword "REST" is to be used for identifying RESTful service and keyword "SOAP" to be used for identifying a SOAP service. |
wsSetRequestHeaderParam | This command is used to set the request header parameters for the service under test. The most common params are Content-Type & Content-Length. This command can be repeated with multiple header parameters. |
wsSetRequestHeaderParamsFromDataFile | This command can be used in replacement with wsSetResponeHeaderParam command where multiple wsSetResponeHeaderParam instructions are required to set the header params within an wsBlock. Instead of creating separate instructions with the command "wsSetResponeHeaderParam" within the test script, a better alternative is to dynamically load the header parameters for the request from a Data File, optionally passing a Data Filter. In the Data File, all header request fields that are common across all services can be set. A filter on the data file, if passed, should filter the data file that contains the header request field params based on the filter. |
wsSetRequestMethod | This command is used to set the request method. Request methods supported are GET, POST, PUT and DELETE for REST Services. In case of SOAP, we need to pass the Operation Name present in the Web Services Description Language(WSDL). |
wsSetRequestPayload | This command is used to set the input payload to the service under test. In case of SOAP web service, if the operation name accepts multiple parameters then the comma separated values must be passed to this command. Please note the sequence of the values and the parameter should be the same. The payload should match the type of the data that is mentioned in the "Content-Type" request header parameter. |
wsSetRequestTimeOut | This command can be used to set the "timeout" for all service requests that get executed in the context of a wsBlock. Test execution gets aborted if no response comes back from Worksoft SaaS wsCONNECT tunnel within the value set. If this command is NOT used within a wsBlock, a default value will be applied for the timeout. |
wsSetRequestURL | This command must be present at least once for Block. If it appears more than once within a wsBlock the URL that corresponds to the last used command will be used to execute the services test. A variable could be used for the entire URL or portions thereof. For public-facing service under test full URL should be mentioned. For example to schedule a test in Worksoft SaaS using REST API: While invoking services behind the firewall, base URL is not be mentioned. URL mentioned here should consist of Resource and Action. For example:/${domainname}/executions/ For SOAP Service under test full URL should be mentioned for both Public facing services and for the services behind the firewall. |
wsSetRequestURLParam | This command is used when some data needs to be sent to the service within the URL as params for executing the service. This command takes input parameters from URL send this data to the specific service. This command can be repeated. The order in which the params are set using this command is the order in which the parameterized URL will be constructed when wsExecuteRequest instruction is executed within CE. |
wsSetResponeHeaderParam | This command is used to set the MIME types.Some of them are application/JSON, application/XML, text/plain, text/HTML, text/javascript etc. |
wsSetResponseHeaderParamsFromDataFile | This command can be used instead of OR in addition to the use of one or more 'wsSetResponseHeaderParam' commands within wsBlock. In the Data File, all header response fields that are common across all services can be set. A filter on the data file, if passed, should filter the data file that contains the header response field presets based on the filter. |
wsSetTestOutcomesforResponseHttpStatusCodes | The purpose of this command is to give an option to the user to specify the status code which they want to pass or fail. The wsExecuteRequest command code needs to take the specific status code from the wsSetTestOutcomesforResponseHttpStatusCodes command and decide whether to pass or fail the wsExecuteRequest command. Example : wsSetTestOutcomesforResponseHttpStatusCodes((200,P || 400,P),null) |
wsSetUsername | This command is used to specify the username to be used for authentication in the service under test. This command is to be used only when the service under test is public facing. For services that are behind the firewall and for the runs wsCONNECT component is used, this command is ignored. |