Difference between revisions of "I2Rest Basic Test"
(→SOAP UI) |
Pavel.lobko (talk | contribs) |
||
(15 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | {{DISPLAYTITLE:i2Rest | + | {{DISPLAYTITLE:Test i2Rest Server demo API}} |
− | + | I2RESTECHO is a service included in i2Rest package for demonstration purposes. It does nothing more than replies to request with the counter value.<br/> | |
− | I2RESTECHO is a service included in i2Rest package for | + | You can test it with any available REST client. Below are examples how to call i2Rest Server using i2Rest Client, SoapUI and cURL. |
− | + | __TOC__ | |
− | + | ==i2Rest Client== | |
The easiest way to test your i2Rest Server is to call service ECHO using [[I2Rest_Client|i2Rest Client]]. i2Rest Client is supplied in i2Rest package, you don't need any REST testing tool installed.<br> | The easiest way to test your i2Rest Server is to call service ECHO using [[I2Rest_Client|i2Rest Client]]. i2Rest Client is supplied in i2Rest package, you don't need any REST testing tool installed.<br> | ||
− | Make sure i2Rest library is in the library list, and just execute the next command (where <Main Gate URL> is the value, that was set up during [[ | + | Make sure i2Rest library is in the library list, and just execute the next command (where <Main Gate URL> is the value, that was set up during [[I2Rest_quick_config|demo server configuration]]) : |
<pre> | <pre> | ||
I2REST COMMAND(*POST) | I2REST COMMAND(*POST) | ||
Line 39: | Line 39: | ||
As you can see i2rest Server responded with "OK" status 200, and the response contains ECHO output object. | As you can see i2rest Server responded with "OK" status 200, and the response contains ECHO output object. | ||
− | + | ==SOAP UI== | |
We assume that you already have Soap UI installed. If not, open source installation package could be found on https://www.soapui.org/downloads/soapui/.<BR> | We assume that you already have Soap UI installed. If not, open source installation package could be found on https://www.soapui.org/downloads/soapui/.<BR> | ||
Run SOAP UI, then go to File ---> New REST Project. Specify URI to request as follows:<br> | Run SOAP UI, then go to File ---> New REST Project. Specify URI to request as follows:<br> | ||
Line 45: | Line 45: | ||
where <Main Gate URL> is the value, that was set up during [[I2Rest_quick_config|initial server configuration]].<br> | where <Main Gate URL> is the value, that was set up during [[I2Rest_quick_config|initial server configuration]].<br> | ||
<div style="padding-bottom:6px">[[File:Echo-soapui-2.png]]<div> | <div style="padding-bottom:6px">[[File:Echo-soapui-2.png]]<div> | ||
− | + | Change request method for POST, then choose or type "application/json" in Media type and provide request body: | |
<pre> | <pre> | ||
{ | { | ||
Line 59: | Line 59: | ||
<div style="padding-bottom:6px">[[File:Echo-soapui-4.png|800px]]<div> | <div style="padding-bottom:6px">[[File:Echo-soapui-4.png|800px]]<div> | ||
− | + | ==cURL== | |
− | We assume that you already have cURL installed. | + | |
− | <pre>curl -X POST -H "Content-Type: application/json" -d @body.json --output response.json http://api.i2Rest.com: | + | We assume that you already have cURL installed.<br> |
+ | The following example is valid for Microsoft Windows, cURL comand for other platforms differs in a few details.<br> | ||
+ | Create Body.json file and copy-paste the next lines: | ||
+ | <pre> | ||
+ | { | ||
+ | "input":{"echo":"0"}, | ||
+ | "joblog":true, | ||
+ | "tracein":true, | ||
+ | "traceout":true | ||
+ | } | ||
+ | </pre> | ||
+ | Run the Windows command interpreter, then change directory to one containing body.json. Execute comand bellow: | ||
+ | <pre>curl -X POST -H "Content-Type: application/json" -d @body.json --output response.json http://api.i2Rest.com:22088/run_program/echo/echo</pre> | ||
+ | Check the result in response.json file being created in the directory containing body.json: | ||
+ | <pre> | ||
+ | { | ||
+ | "output": { | ||
+ | "echo": "2" | ||
+ | }, | ||
+ | "joblog": [ | ||
+ | "Input:", | ||
+ | "echo (10):", | ||
+ | "000000 :0 :F0 00 00 00 00 00 00 00 00 00", | ||
+ | "Output:", | ||
+ | "echo (10):", | ||
+ | "000000 :2 :F2 00 00 00 00 00 00 00 00 00" | ||
+ | ], | ||
+ | "job": "123456/USRX/JOBNAME" | ||
+ | } | ||
+ | </pre> |
Latest revision as of 12:33, 8 July 2020
I2RESTECHO is a service included in i2Rest package for demonstration purposes. It does nothing more than replies to request with the counter value.
You can test it with any available REST client. Below are examples how to call i2Rest Server using i2Rest Client, SoapUI and cURL.
Contents
i2Rest Client
The easiest way to test your i2Rest Server is to call service ECHO using i2Rest Client. i2Rest Client is supplied in i2Rest package, you don't need any REST testing tool installed.
Make sure i2Rest library is in the library list, and just execute the next command (where <Main Gate URL> is the value, that was set up during demo server configuration) :
I2REST COMMAND(*POST) URL('<Main Gate URL>/run_program/echo/echo') BODY(*N '{"input":{"echo":"0"}, "joblog":true, "tracein":true, "traceout":true}' 'application/json') OUTPUT(*JOBLOG) AUTHMETHOD(*NONE)
And check the result in joblog:
Server response (status 200, shown 280 bytes of 280): { "output": { "echo": "2" }, "joblog": [ "Input:", "echo (10):", "000000 :0 :F0 00 00 00 00 00 00 00 00 00", "Output:", "echo (10):", "000000 :2 :F2 00 00 00 00 00 00 00 00 00" ], "job": "123456/USRX/JOBNAME" }
As you can see i2rest Server responded with "OK" status 200, and the response contains ECHO output object.
SOAP UI
We assume that you already have Soap UI installed. If not, open source installation package could be found on https://www.soapui.org/downloads/soapui/.
Run SOAP UI, then go to File ---> New REST Project. Specify URI to request as follows:
<Main Gate URL>/run_program/echo/echo
where <Main Gate URL> is the value, that was set up during initial server configuration.

Change request method for POST, then choose or type "application/json" in Media type and provide request body:
{ "input":{"echo":"0"}, "joblog":true, "tracein":true, "traceout":true }
Then submit request.

Find server responce under the JSON tab:

cURL
We assume that you already have cURL installed.
The following example is valid for Microsoft Windows, cURL comand for other platforms differs in a few details.
Create Body.json file and copy-paste the next lines:
{ "input":{"echo":"0"}, "joblog":true, "tracein":true, "traceout":true }
Run the Windows command interpreter, then change directory to one containing body.json. Execute comand bellow:
curl -X POST -H "Content-Type: application/json" -d @body.json --output response.json http://api.i2Rest.com:22088/run_program/echo/echo
Check the result in response.json file being created in the directory containing body.json:
{ "output": { "echo": "2" }, "joblog": [ "Input:", "echo (10):", "000000 :0 :F0 00 00 00 00 00 00 00 00 00", "Output:", "echo (10):", "000000 :2 :F2 00 00 00 00 00 00 00 00 00" ], "job": "123456/USRX/JOBNAME" }