Difference between revisions of "I2Rest Basic Test"

From i2Rest
Jump to: navigation, search
(SOAP UI)
Line 1: Line 1:
 
{{DISPLAYTITLE:i2Rest basic implementation}}
 
{{DISPLAYTITLE:i2Rest basic implementation}}
==ECHO==
+
==I2RESTECHO==
ECHO is a service included in i2Rest package for testing purposes. It does nothing more than replies to request with the counter value.
+
I2RESTECHO is a service included in i2Rest package for testing purposes. It does nothing more than replies to request with the counter value.<br>
 +
All we have to do to start using I2RESTECHO is to provide program call parameters formal description. Look at such a description for the I2RESTECHO:
 +
<pre>
 +
<pcml version="1.0">
 +
 
 +
<program name="echo" path="/QSYS.LIB/I2REST.LIB/I2RESTECHO.PGM">
 +
      <data name="echo"  usage="inputoutput"  type="char"  length="10" trim="both"/>
 +
</program>
 +
 
 +
<pcml>
 +
</pre>
 +
Create I2RESTECHO.PCML file and copy-paste the lines above to it. Now the file has to be saved on IFS according to the path specified on the [[I2Rest_Server_quickstart|server configuring step]], i.e on "/QSYS/I2REST/PCML/i2restecho.pcml"
 +
<pre>  {"pcml_mount":"echo",    "pcml_file":"/QSYS/I2REST/PCML/i2restecho.pcml", "valid_in_anonymous":true} </pre>
 +
You can store your pcml-files anywhere your like, just make sure that pathes in config.json are correct.<br>
 +
We are ready to start!
 
===i2Rest Client===
 
===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>

Revision as of 12:48, 8 June 2020

I2RESTECHO

I2RESTECHO is a service included in i2Rest package for testing purposes. It does nothing more than replies to request with the counter value.
All we have to do to start using I2RESTECHO is to provide program call parameters formal description. Look at such a description for the I2RESTECHO:

<pcml version="1.0">

<program name="echo" path="/QSYS.LIB/I2REST.LIB/I2RESTECHO.PGM">
      <data name="echo"   usage="inputoutput"   type="char"  length="10" trim="both"/>
</program>

<pcml>

Create I2RESTECHO.PCML file and copy-paste the lines above to it. Now the file has to be saved on IFS according to the path specified on the server configuring step, i.e on "/QSYS/I2REST/PCML/i2restecho.pcml"

  {"pcml_mount":"echo",     "pcml_file":"/QSYS/I2REST/PCML/i2restecho.pcml", "valid_in_anonymous":true} 

You can store your pcml-files anywhere your like, just make sure that pathes in config.json are correct.
We are ready to start!

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 initial 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.

Echo-soapui-2.png

Choose "application/json" Media type and provide request body:

{
     "input":{"echo":"0"},
     "joblog":true,
     "tracein":true, 
     "traceout":true
}

Then submit request.

Echo-soapui-3.png

Find server responce under the JSON tab:

Echo-soapui-4.png

cURL

We assume that you already have cURL installed.

curl -X POST -H "Content-Type: application/json" -d @body.json --output response.json http://api.i2Rest.com:22089/run_program/echo/echo