This is documentation for Caché & Ensemble. See the InterSystems IRIS version of this content.

For information on migrating to InterSystems IRIS, see Why Migrate to InterSystems IRIS?


class DeepSee.RESTClient extends

REST Application test bed
This is just a quick graphical alternative to cURL for people who need to exercise the API but hate to type
Out of the box, this sample was designed to run against the DocServer example in SAMPLES, but this can be customized by changing the SERVERCLASS parameter to point to a different subclass of %CSP.REST, and changing the cspApplication property to match the dispatch application defined in the management portal.
This page should be hosted on the same server that provides the REST services as it uses its own location.hostname properties for getting the host and port number of the server
Additionally, the processRequest() method has a username and password pair hardcoded into the method to save typing, this is fine for personal desk checking but should be customized or removed before sharing this code

Property Inventory

Method Inventory


parameter JSINCLUDES = zenCSLM.js,zenESVG.js,DeepSee.js;
Inherited description: Comma-separated list of additional JS include files for the page.
parameter SERVERCLASS = %DeepSee.REST.v1;
This is the name of the CLASS that defines the UrlMap (the core of a REST service) that you wish to explore, it should be a subclass of %CSP.REST


property cspApplication as %ZEN.Datatype.string [ InitialExpression = "/api/deepsee" ];
This is the name of the REST dispatcher as defined in the SMP
Property methods: cspApplicationDisplayToLogical(), cspApplicationGet(), cspApplicationIsValid(), cspApplicationLogicalToDisplay(), cspApplicationLogicalToOdbc(), cspApplicationNormalize(), cspApplicationSet()
property namespace as %ZEN.Datatype.string [ InitialExpression = "SAMPLES" ];
Property methods: namespaceDisplayToLogical(), namespaceGet(), namespaceIsValid(), namespaceLogicalToDisplay(), namespaceLogicalToOdbc(), namespaceNormalize(), namespaceSet()
property requestUrl as %ZEN.Datatype.string;
Container for the current URL actually being used to send the request
Property methods: requestUrlDisplayToLogical(), requestUrlGet(), requestUrlIsValid(), requestUrlLogicalToDisplay(), requestUrlLogicalToOdbc(), requestUrlNormalize(), requestUrlSet()
property server as %ZEN.Datatype.string;
Property methods: serverClassDisplayToLogical(), serverClassGet(), serverClassIsValid(), serverClassLogicalToDisplay(), serverClassLogicalToOdbc(), serverClassNormalize(), serverClassSet(), serverDisplayToLogical(), serverGet(), serverIsValid(), serverLogicalToDisplay(), serverLogicalToOdbc(), serverNormalize(), serverSet()
property serverClass as %ZEN.Datatype.string [ InitialExpression = ..#SERVERCLASS ];
Property methods: serverClassDisplayToLogical(), serverClassGet(), serverClassIsValid(), serverClassLogicalToDisplay(), serverClassLogicalToOdbc(), serverClassNormalize(), serverClassSet()


method %OnAfterCreatePage() as %Status
This callback is called after the server-side page object and all of its children are created.
Subclasses can override this to add, remove, or modify items within the page object model, or to provide values for controls.
classmethod GetRouteData(pDispatchClass="") as %ZEN.Datatype.string [ ZenMethod ]
Read the UrlMap XData section from the class given in the SERVERCLASS parameter and export it as a block of XML. This is used by the client page to generate on-screen request forms for exercising the various paths.
clientmethod buildRouteObject(xmlNode, prefix) [ Language = javascript ]
clientmethod changeApplication() [ Language = javascript ]
clientmethod changeNamespace() [ Language = javascript ]
clientmethod clearResponseArea() [ Language = javascript ]
clientmethod getRoutes() [ Language = javascript ]
The route data comes down from the server as an XML block (from the XData section of whatever SERVERCLASS was defined) and needs to be converted to a JavaScript object for local processing. The server side call here is the only reason this page happens to be a Zen page, all the work done creating XMLHttpRequest objects could have been done from any HTML5 web page, REST does not require the client to be Zen or even CSP.
clientmethod isSystemApplication() [ Language = javascript ]
clientmethod onloadHandler() [ Language = javascript ]
Inherited description: This client event, if present, is fired when the page is loaded.
clientmethod processRequest() [ Language = javascript ]
This builds up an abstract model of a request object based on values entered into the generated form. NOTE that the username and password have been hard-coded here for speed of testing.
clientmethod processResponse(xhr) [ Language = javascript ]
Local method to just spit out the body of the response object
clientmethod renderRequestForm(idx) [ Language = javascript ]
Generate a basic form for the most common options people are likely to need when desk checking a REST url Map. For GET requests the options are fairly limited. For PUT and POST requests, you have the option of entering text for the body of the request, or selecting a file from disk. If a disk file is selected, the contents of the text area widget on screen is ignored.
clientmethod renderRoutes(rd) [ Language = javascript ]
Renderer for client-side projection of the URL
clientmethod selectRoute(idx) [ Language = javascript ]
Callback function to highlight the last clicked-upon service and call out to generate a form
clientmethod setRouting() [ Language = javascript ]
clientmethod submitRequest(r) [ Language = javascript ]
This generic method takes a request profile in the form of a JS object and initiates a simple HTTP Request. The request profile may include the any of the following:
url - the resourse to request
method - the method to use, one of GET, PUT, POST or DELETE
user - user name for authentication purposes
passwd - user password for authentication purposes
acceptType - preferred MIME type for the response
contentType - MIME type of request body
body - content of request body
async - flag to indicate request should be made asynchronously
callback - method to when complete (request object will be passed in as sole parameter)

Inherited Members

Inherited Properties

Inherited Methods