Plugging-in server REST API

Top  Previous  Next

Architecture

 

REST API allows you to redefine parameters, perform authentication and authorization of WCS JavaScript API invocations. You can learn more about the REST API and its settings from the following manuals:

 

Web Call Server - Specification

Web Call Server - Administrator manual

Web Call Server - Call Flow

 

WCS-JS-REST-2

 

By default, the REST API sends requests to the local HTTP address http://localhost:9091/EchoApp. This address gives back what it receives effectively working as 'Echo'.

Open the flashphoner_manager.log log file to see what data are being transmitted via the REST API.

 

 

Data exchange example using REST API

 

The example below shows that data are sent in a JSON object. Your REST API must provide data in the same format and in compliance with the Web Call Server - Call Flow specification. If you have questions regarding the data sent, open the flashphoner_manager.log and see how the data runs in the working example Phone.html and the standard app EchoApp.

 

16:54:29,197 RECEIVED REST OBJECT <==

URL:http://localhost:9091/EchoApp/connect

OBJECT:

{

 "appKey" : "defaultApp",

 "sessionId" : "/92.127.197.142:63853/101.226.225.55:8080",

 "sipRegisterRequired" : true,

 "mediaProviders" : [ "WebRTC" ],

 "useSelfSigned" : false

}

16:54:29,315 SEND REST OBJECT ==>

URL:http://localhost:9091/EchoApp/ConnectionStatusEvent

OBJECT:

{

 "appKey" : "defaultApp",

 "sessionId" : "/92.127.197.142:63853/101.226.225.55:8080",

 "sipRegisterRequired" : true,

 "mediaProviders" : [ "WebRTC" ],

 "useSelfSigned" : false,

 "authToken" : "/92.127.197.142:63853/101.226.225.55:8080",

 "status" : "ESTABLISHED"

}

16:54:29,327 INFO RECEIVED REST OBJECT <==

URL:http://localhost:9091/EchoApp/ConnectionStatusEvent

OBJECT:

{

 "appKey" : "defaultApp",

 "sessionId" : "/92.127.197.142:63853/101.226.225.55:8080",

 "sipRegisterRequired" : true,

 "mediaProviders" : [ "WebRTC" ],

 "useSelfSigned" : false,

 "authToken" : "/92.127.197.142:63853/101.226.225.55:8080",

 "status" : "ESTABLISHED"

}

 

 

Connection

 

To connect your own REST API, open the command line interface of the WCS server and execute the following command:

 

update app defaultApp http://my-web-server.com/MyRestApp

 

, where my-web-server.com is the address of your web-server, and MyRestApp is the path where your REST / HTTP / HTTPS interface is located.

 

Web Call Server will query the following URLs:

 

http://my-web-server.com/MyRestApp/connect

http://my-web-server.com/MyRestApp/ConnectionStatusEvent

http://my-web-server.com/MyRestApp/RegistrationStatusEvent

http://my-web-server.com/MyRestApp/call

http://my-web-server.com/MyRestApp/OnCallEvent

http://my-web-server.com/MyRestApp/CallStatusEvent

 

and so on.

 

Your web-server must respond on these addresses and provide correct JSON objects. Besides, you can forbid the operation by returning a 403 FORBIDDEN HTTP status.

You do not have to implement all the methods. Unnecessary methods can be disabled so they will not be invoked. Use remove app-rest-methods and add app-rest-method commands for that. See Web Call Server - Administrator Manual.