· May 21, 2018

working with Angular

I have a very large logistics software running Chache.

I need to build an external application ( Web & Mobile)  . I was thinking of using Angular. Does anyone have experience with this infrastructure ? What would be the best way to extract the data ?

Discussion (4)1
Log in or sign up to continue

The other answers point to some good resources that you should definitely look at. That said, the answer to your question is to build a REST API. You will need to create a new class that is a subclass of the %CSP.REST class. You can then add a UrlMap block that maps URLs to ClassMethods. Here's a simple example of such a dispatch class: 

Class REST.Handler Extends %CSP.REST

Parameter UseSession As Integer = 1;

/// The UrlMap determines how a Url should map to a HTTP Method and a Target ClassMethod
/// indicated by the 'call' attribute. The call attribute is either the name of a method
/// or the name of a class and method seperated by a ':'.
/// parameters within the URL preceeded by a ':' will be extracted from the supplied URL
/// and passed as arguments to the named method.
XData UrlMap
<Route Url="/HelloWorld" Method="GET" Call="HelloWorld" />

/// A simple test method to ensure that the REST infrastructure is working
ClassMethod HelloWorld()
Set obj = "message""Hello from REST" }
Write obj.%ToJSON()
Quit $$$OK


Finally, you need to create a new web application in the System Management portal and set your class as the Dispatch Class.  Once you have the dispatch class and web application set up, you can point your Angular app to the corresponding URL and use it like you would any other REST API.