10/28/2022 0 Comments Postman web![]() It can also be a valuable tool when testing any changes you make to your RPG programs over time.There is no doubt that Postman is one of the most popular and essential tools for REST API development and testing, particularly for front-end web developers. Of course, if you use RPG-XML Suite to offer your own web services, Postman is a great tool for testing your RPG-XML Suite programs being served by Apache during the development process. #Postman web code#If you have RPG-XML Suite installed, you can also locate the example RPG code in the RXS/QRPGLESRC source file. If this web service seems vaguely familiar to you, it’s because this particular web service corresponds with the CELSIUS example program located on this page from the RPG-XML Suite documentation site: Once you have your test configured and working correctly, you will want to click Save so that you can easily re-run this test in the future. In the case of more complicated web services, you could add as many tests as needed, and still be able to easily and visually determine whether all passed or quickly locate those in red that may have failed. We can get further confirmation of the test result by clicking on the Tests tab and noting the additional green “Pass” indicator and text that tells us our test is successful. This gives us some immediate feedback that the test code successfully verified that the response contained the data we had configured for testing. You should also notice that Postman displays the text (1/1) in green as part of the Tests tab. The resulting response in the Body tab of the response should display the XML returned by the remote server, and within that content you should see the value 37.7777777777778 which is highlighted in the below screenshot. Now we are ready to send the configured request to the remote URL by clicking Send. The last line of code is the result of deciphering the generated JSON from the console window and then converting that JSON to the equivalent syntax needed to test the value returned in FahrenheitToCelsiusResult. This window will show the detail of each transaction you run and will also show the output of any console.log requests. Simply click on View and then Show Postman Console and you will notice that a separate window will open. When you’re developing your own tests in the future you will likely want to use this code so that you can decipher the exact syntax needed for the test. ![]() Next, you will notice a commented line of code (line 2) that when not commented, is helpful for viewing the generated JSON code. (We’re hopeful that in the future the authors of Postman will enhance the testing function to allow the use of XPath statements for direct testing of XML responses without requiring conversion of XML to JSON.) So the first line of code we need is for converting the XML to JSON format, which will then allow us to code the remainder of the test using JSON type syntax. This is a bit more complicated for a XML-based service than for a JSON-based service because Postman only supports the use of JSON syntax when running its testing code. Now click on the Tests tab so that we can define the code that Postman will use to automatically check the response for accuracy. ![]() ![]() Now click on the Body tab, and paste the following XML request: Next, click on the Headers tab so that you can input the two required HTTP headers into your request configuration: SOAPAction: "" Next, just to the right of POST, add the URL for the web service, in this case: (Note that installing the App for Windows, Mac, or Linux is preferred over installing Postman for Chrome.)Īfter starting Postman, simply click on a new tab (one with a + sign) and then begin by selecting POST from the dropdown. If you don’t already have a copy of Postman, please visit this page: The purpose of the web service is to convert temperatures and it will demonstrate how Postman can be configured to test the accuracy of the response returned by the web service. The following tutorial will detail using Postman to develop a test of a XML web service. However, it is often overlooked that Postman can also be used to perform and automate testing of web services. Postman has become a popular ad hoc tool for use when developing new web services. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |