Do you think IIT Guwahati certified course can help you in your career?
No
Introduction
This article will teach about Routing and recording in ready API. Before starting with the topic, lets us understand What is Ready API? A Ready API is an intuitive no-code API testing tool intended to make your testing processes more efficient. There are many features of the testing and it provides a wide variety of software integrations for JMS, JDBC, SOAP, REST APIs testing, and many more.
Why Routing?
Routing is the process through which a virtual API sends incoming requests to a real web service, receives its response, and sends it back to the client. As a transparent proxy, the virtual service acts as a bridge between the client and a real API when routing is enabled.
Consider that you are creating a new iteration of your current API. You build a new virtual service and direct "existing" processes to your live web service to test it. After then, only new operations will need to be virtualized.
Seamlessly go from a virtual service to a real API without altering the client code. Consider doing a virtual service that impersonates an API. Up till the API server component is available, you can use this service to write client code or API testing. You send developers the corresponding virtual operations when they finish some actual server-side operations. You route more virtual operations after a few more "actual" operations are prepared, and you keep doing this until all the real operations are complete. Using this strategy, you can prevent modifications to client code or testing during development.
ReadyAPI will build virtual operations from the traffic that was observed.
You can examine your actual API's responses to clients by turning on routing and recording. You can then utilize these responses as the foundation for the virtual responses of your virtual API.
Setting Up Routing
Set the service routing options
Select one of the options from the drop-down menu.
Credit: support.smartbear.com
Set routing mode for operations
You need to select the Routing Mode from the drop-down menu.
Credit: support.smartbear.com
Credit: support.smartbear.com
Enable response recording
The virtual service receives responses from an existing API for routing requests. If necessary, you can save these responses to the service.
Recording Requests and Responses
Request Recording
You must choose the Route and Record Non-Virted Requests routing mode for your virtual service to enable request recording:
Credit: support.smartbear.com
Response recording
Real API answers can also be recorded. Any routing style can use this functionality, which is useful if you want to supplement your virtual service with actual API responses.
To enable response recording, check the Record Responses box for the chosen "routed" action:
Credit: support.smartbear.com
Limitations
REST, SOAP, and JDBC virtual services can all be routed. For JMS virtual services, it is not accessible.
Routing prevents some virtual services from running on the same computer simultaneously as other services. ReadyAPI will indicate an error if you start this virtual service while another service is already running. Launching another virtual service while your routing service runs will similarly report an error.
The Route and Record Non-Virtualized Requests mode does not accurately record authentication requests to the servers that utilize Kerberos authentication due to the peculiarities of this authentication type. For this, you might try employing a workaround.
Add Recorded Operations to Virtual Service
Configuring Properties
Activate the virtual service editor.
From the Route Options drop-down box, select Switch Route and Record Non-Virted Request as shown below:
Credit: support.smartbear.com
This parameter instructs the virtual service to route any incoming requests for which it does not currently have a virtual operation and to build the virtual operation from the routed request and the real API response.
Recording Traffic
Click run to start the virtual service.
Utilize your client application, browser, ReadyAPI, or any other tool to send requests to the virtual service. ReadyAPI will build a virtual operation and record the routed requests and responses flow.
Conditional Routing
Using the conditional routing option, you can enable or disable routing for particular requests.
To determine whether the virtual service should route a request or not, you create a Groovy script code. The service runs this code for each incoming request that matches the virtual action for which conditional routing was enabled.
The return keyword is used in Groovy scripts to return results. If the return keyword is absent from the script, ReadyAPI will use the value from the final script line.
Setting Up Properties
For your virtual service, enable routing, and choose Conditional from the Routing Mode combo box for the desired action.
When the Conditional value has been chosen, ReadyAPI will show the editor on the right. Write the Groovy script code and choose Conditional Routing in the editor:
Credit: support.smartbear.com
Writing Script Code
The return keyword in a Groovy script is used to return the outcome. If the return keyword is absent from the script, ReadyAPI will use the value from the final script line.
mockRequest: Provides access to the incoming request's header, body, and parameters through its methods and properties.
log: Posting messages to the Script log has methods and properties. Click Logs at the bottom of the ReadyAPI window and select the Script log tab to view it.
Click run to run the entered expression. Your entered Groovy code will be executed by the virtual service, which will then indicate whether or not the request will be forwarded. You must send a sample request to the virtual service to use this functionality. Run the virtual service first, then replicate the client mobile application request using ReadyAPI Test or another tool.
Routing and Recording Request to Kerberos Servers
For servers that employ Kerberos authentication, authentication requests are typically not stored correctly in the Route and Record Non-Virtualized Requests routing mode due to the intricacies of how Kerberos authentication is implemented. They can be recorded only if the virtual service and the tested server run on the same machine and can be contacted using localhost. This is an exception, as virtual servers and services frequently run on different machines.
Launch the window for API discovery. Selecting the APIs (Virtual) node in the Navigator and choosing Discover from the toolbar will accomplish this:
Credit: support.smartbear.com
Change the discovery engine's mode to proxy:
Credit: support.smartbear.com
Credit: support.smartbear.com
Make use of the data displayed in the Discovery box to configure your client application.
Your client application should send the server authentication requests. The client application and the server will be connected through the ReadyAPI proxy. The requests and responses will be tracked, and the Transactions page will show them:
Credit: support.smartbear.com
To add the recorded requests and responses to your virtual service, pause the recording and then select Add to Existing Virtual Service:
Credit: support.smartbear.com
Frequently Asked Questions
What does REST stand for?
REST stands for "Representational state transfer". A Representational state transfer API is a web API that complies with the restrictions of the REST architectural style and enables communication with RESTful web services.
What is the difference between REST and RESTful?
The set of constraints is called REST. A RESTful API complies with certain limitations. It can be used for software, applications, and web services.
Is REST API either frontend or backend?
REST is a widely used technique for creating backend APIs. But during the last ten years, REST APIs have become the standard for creating backend APIs. And a lot of businesses and developers actively use it in their projects.
How can we make ReadyAPI accept request parameters?
You may add all the arguments if you have utilized a REST URL. Click to open the follow-up dialogue, then type the URL. ReadyAPI will examine the request and all its parameters added to the database.
Is ReadyAPI free and open source?
ReadyAPI Virtualization is a member of the ReadyAPI family that is not included in SoapUI Open Source. As a result, any ReadyAPI Virtualization or virtual service functions will not work in SoapUI Open Source.
Conclusion
In the article, we learned about Routing and recording in ready API. We hope this article will help you understand the Routing concept in Ready API. Check out our other blogs on the topic of Ready API: