Skip to content

How do I access a web service which is not accessible in the public domain

This example demonstrates accessing web service from a domain that is not public.

In the solution shown below, you specify the tunnel name configured in the Worksoft SaaS using the "wsSetContext" command and specify the request method for accessing the web service(Ex:- POST, GET, PUT, etc.) and the authentication type(Ex: Basic). The user name and password by using "wsSetUsername" and "wsSetPassword" commands.

Solution:

# Command Target Value
To Open the wsBlock to access the service
1 wsBlockOpen

To specify to Worksoft SaaS the "wsConnect tunnel" and "alias name" names
2 wsSetContext TunnelName AliasName
To set the request URL
3 wsSetRequestURL URL_to_be_specified_here requestURL
To specify the method used for accessing the service
4 wsSetRequestMethod POST
To specify the authentication type of the web service
5 wsSetAuthenticationType Basic
To set the User Name
6 wsSetUserName username
To set the Password
7 wsSetPassword password
Contains the Request Parameters of the Service
8 wsSetRequestHeaderParam Content-type application-json
The request is stored in a JSON format that is given in the Value field
9 wsExecuteRequest place_request_JSON_here response
This command is used to set the HTTP response status code to the service under test
10 wsGetResposnseHttpStatusCode responseCode
To Close the wsBlock after accessing the service
11 wsBlockEnd

Tips, Tricks, Gotchas & Best Practices:  

  • All the Web Services commands should be in between "wsBlockOpen" and "wsBlockEnd".
  • Authentication type should be given before username and password.


Feedback and Knowledge Base