User Tools

Site Tools


engine:webservices:start

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
engine:webservices:start [2015/07/01 22:38]
asok
engine:webservices:start [2017/06/20 17:13] (current)
asok [Testing a Web Service using catest]
Line 22: Line 22:
  
 Query format - **name**_q.json Query format - **name**_q.json
 +
 Response format - **name**_r.json Response format - **name**_r.json
 +
 Method - **name**.method Method - **name**.method
  
-DreamApps doesn'​t allow any web service without authentication. So, all calls to DreamApps web services need a sessionid which is obtained by a call to authentication web service **zx_auth** which returns a sessionid on successful authentication.+**DreamApps doesn'​t allow any web service without authentication.** So, all calls to DreamApps web services need a sessionid which is obtained by a call to authentication web service **zx_auth** which returns a sessionid on successful authentication. 
 + 
 +Try the method **ca_test_server.method** for an example of using the web service **ca_test**,​ which is implemented by **ca_test_q.json**,​ **ca_test_r.json** and **ca_test.method**. 
 + 
 +====Creating,​ Extracting and Inserting Data in JSONs==== 
 + 
 +There is a single system function **#json** to manipulate JSONs in DreamApps. It can take up to 3 parameters. 
 + 
 +Creating a JSON needs just one parameter and can have two formats. 
 + 
 +<​file>​ 
 + str s=#​json(file "​filename.json"​) 
 + 
 +</​file>​ 
 +or, 
 +<​file>​ 
 + str s=#​json("​valid-text-string"​) 
 + 
 +</​file>​ 
 + 
 +Extracting a field-value from a JSON needs 2 parameters. 
 +<​file>​ 
 + str s=#​json(json-string-name,​ key) 
 + 
 +</​file>​ 
 + 
 +Inserting a field-value into a JSON needs 3 parameters. 
 +<​file>​ 
 + str s=#​json(json-string-name,​ key, field-value)
  
-Try the method **ca_test_server.method** for an example of using the web service **ca_test**.+</​file>​
  
 +See the method ​ **ca_test_server.method** for examples of #json usage.
 +====Testing a Web Service using catest====
  
 +Here is an example. Run something like the followings: ​
 +<​code>​
 +str host="​http://​ig.dreamapps.com/​da/​ws"​
 +set s=#​json(file "​zx_auth_q.json"​)
 +set s=#​json(s,"​businessid","​630006"​)
 +set s=#​json(s,"​username","​asok@dreamapps.com"​)
 +set s=#​json(s,"​password","​go"​)
  
 +set s=#​http(host,"​POST",​s)
 + 
 +print s
 +</​code>​
/srv/www/htdocs/wiki/data/attic/engine/webservices/start.1435790317.txt.gz · Last modified: 2015/07/01 22:38 by asok