Skip Navigation

Using JavaScript to Access SRWRuntime Communication Services

If your web app accesses SRWRuntime communication servicess with JavaScript, use this procedure.

If your web app accesses the whitelisted OSGi non-communications services, see Using JavaScript to Access OSGi Non-communications Services.

SRWRuntime is an OSGi service that opens access to other SRWRuntime communications functionality. The simplified API is now being provided for your convenience, so you don’t have to call the service process or processJSON methods directly.

Communication Services Authorization

To access ISRWRuntime communications channels with JavaScript, request authorization in your redapp.xml file for the channels that you want to use. Authorization requests for web apps that are based on both JavaScript and Java are the same.

Before you begin, add an Authorization entry to your redapp.xml file for the OSGi service. A sample entry is shown below. For complete information, see Authorization to Access or Use Services in "Building a redapp.xml File."

<Authorization name=__""__ threshold=__"10"__ metric=__"tpm"__ />

With the new, simplified API for accessing SRWRuntime Communication is much simpler. You do not need to obtain an authentication token or build JSON requests anymore.

Here is sample code to demonstrate the easy of calling SWS:

var rsp = SrwApi.sws(command, action);
rsp = eval ("("  rsp  ")");
if(rsp.response.success == 'true'){
    var resonseText = rsp.response.payload.responseText;
To use the simplified API, you must use (or inherit from) DefaultWebkitEditor or WebkitView class from the com.sabre.edge.platform.optional.webkit plug-in.

Available JavaScript functions:

Closing the active Web Editor or Web View

  • SrwApi.end()

Lock/unlock services

  • rsp = SrwApi.lock()

  • rsp = SrwApi.lock(timeout)

  • rsp = SrwApi.unlock(lockId)

Host service

  • rsp =

  • rsp =, lockId)

SDS service

  • rsp = SrwApi.sds(appId, subsetId, actionCode)

  • rsp = SrwApi.sds(appId, subsetId, actionCode, lockId)

Show/Execute in Emulator services

  • rsp = SrwApi.showInEmu(command)

  • rsp = SrwApi.showInEmu(command, isCommand)

  • rsp = SrwApi.executeInEmu(command)

  • rsp = SrwApi.executeInEmu(command, showCommand, showResponse)

SWS service

  • rsp = SrwApi.sws(xml, action)

  • rsp = SrwApi.sws(xml, action, lockId)

Highlight service

  • rsp = SrwApi.getHighlight()

SSO service

  • rsp = SrwApi.sso(serviceProvider, assertionParams)


To each of specified above function you can add at the end of argument list a callback function referenced via its name (prefixed with “cb:<name>”) then callback function will be executed synchronously after parent method is finished. Callback function is one-argument function. The argument is a result of parent method execution.

Example of usage:

function callbackHandler(rsp){
    if(rsp.response.success == 'true'){
        var resonseText = rsp.response.payload.responseText;

SrwApi.sws(xml, action, 'cb:callbackHandler');
lockId and timeout must be a non-negative integer numbers. isCommand, showCommand, showResponse must be a boolean value.