User Tools

Site Tools


engine:webservices:start

Differences

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

Link to this comparison view

Next revision
Previous revision
engine:webservices:start [2015/07/01 22:19]
asok created
engine:webservices:start [2017/06/20 17:13] (current)
asok [Testing a Web Service using catest]
Line 11: Line 11:
  
 The raw response from the host may be encoded in a JSON, XML or any other format as defined by the API. You will need to extract the relevant data from the raw response. Try the method **ca_test_client.method** for an example. The raw response from the host may be encoded in a JSON, XML or any other format as defined by the API. You will need to extract the relevant data from the raw response. Try the method **ca_test_client.method** for an example.
 +
 +====Web Service Server - RESTful with JSON ====
 +To publish a RESTful web service in DreamApps, you will need to define
 +
 +  - a JSON query format - must have parameters method, sessionid and any number of other parameters ​
 +  - a JSON response format - must have parameters status and any number of other parameters
 +  - a method to generate the response from the query.
 +
 +**While naming the resources, please follow the following convention to avoid confusion.**
 +
 +Query format - **name**_q.json
 +
 +Response format - **name**_r.json
 +
 +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.
 +
 +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)
 +
 +</​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.1435789174.txt.gz · Last modified: 2015/07/01 22:19 by asok