How to create a REST web application using a Installer manifest
Just like the title says, I'm attempting to find a way to create a web application that instead of serving CSP files, it uses a dispatch class.
I searched for clues in the documentation, but the CSPApplication tag seems to be exclusively for CSP file-based applications.
I'm trying to avoid implementing a workaround such as using the Invoke tag to call the Security.Applications to generate the web application but I might be forced to do so, even though it's unpleasant if I had to say...
So, is there an official way to execute this task?
Invoke is the way to go.
And invoke with
The code for CSPApplication appears to accept DispatchClass (even though documentation does not say it). I have not yet tested it. But in PivotSubscriptions I create my WebApp the way that Eduard says, but I was planning on changing it to use %Installer this week or next.
I might have to check the IRIS version, because my Caché 2018 doesn't have any traces of the DispatchClass configuration.
Method CSPApplication(
pUrl As %String,
pNamespace As %String,
pDescription As %String,
pDirectory As %String,
pResource As %String,
pRecurse As %String,
pLoginClass As %String,
pGrant As %String,
pCookiePath As %String,
pAuthMethods As %Integer,
pLockCSPName As %Boolean,
pEventClass As %String,
pDefaultTimeout As %Integer,
pDefaultSuperclass As %String,
pUseSessionCookie As %Integer,
pServeFiles As %Boolean,
pServeFilesTimeout As %Integer,
pCustomErrorPage As %String,
pPackageName As %String,
pChangePasswordPage As %String,
pGroupById As %String = "",
pCspZenEnabled As %Boolean = 1,
pInboundWebServicesEnabled As %Boolean = 1,
pTwoFactorEnabled As %Boolean = 0,
pIsNameSpaceDefault As %Boolean = 0,
pPermittedClasses As %String = "",
pAutoCompile As %Boolean = 1) [ Internal ]
Yes, it does look like it was included for IRIS
Yeah, I just noticed it now: https://docs.intersystems.com/csp/documatic/%25CSP.Documatic.cls?PAGE=CLASS&LIBRARY=%25SYS&CLASSNAME=%25Installer.CSPApplication
EDIT: I'll make some tests and see if it works fine. I'll report back for you if it does.
I tried this out and it works as expected:
<CSPApplication
Url="/api/pivotsubscriptionsunsubscribe"
Directory="${CSPDIR}"
DispatchClass="PivotSubscriptions.UI.Unsubscribe"
AuthenticationMethods="64"
/>
Wow. This is cool! And what is the version?
I tested this in a 2020.2 IRIS development build.
(Also my code example will be included in PivotSubscriptions v1.6
)
I have also tested it in IRIS 2018.1 and 2019.1
After further testing, it looks like this isn't working as I originally thought. It looks like our only option at this point is to use Security.Applications
From your code above I see that you attempted to use both Directory and DispatchClass attributes. Have you tried removing the Directory attribute?
I seem to get an error when I do not specify Directory:
2020-03-11 08:29:03 0 PivotSubscriptions.Installer: ERROR #5001: - ERROR when creating Portal application: Application name, namespace and directory must not be null
Indeed, I got this error too. However if I use a dummy directory it accepts.
I haven't used this feature yet because I must change plenty of things to actually consume that REST application. But the way I'm seeing things so far I guess it would work.
So what if you provide a dummy directory like: "/tmp/dummycsp" as well?
Even though it isn't throwing an error it is not creating the Web App correctly. If you view your Web App, the Dispatch class is not set
Also, CSPDIR should be a good default value and you probably don't need a dummy directory:
https://docs.intersystems.com/irislatest/csp/docbook/Doc.View.cls?KEY=GC...
Ahh, yes, it could be used that way too.
Either way, basically only the schema is supporting the DispatchClass, the engine itself doesn't, making it looks like a feature that's in development. So I'm sure that will get this feature on the near future.
Well... here's how I did it:
https://github.com/rfns/iris-ci/blob/master/ci/App/Installer.cls
Hi Rubens! Deploy with zpm! It supports this -an article about that.
Can I use the ZPM client like a standalone the same way it works when using the %Installer manifest? Bu that I mean, just calling the ZPM to parse the manifest and install it without relying on the registry and the CLI for now, because all the code I want to import is already local, I just need to create a web application that uses the DispatchClass property.
I don't know, actually. Tagging @Nikolay Soloviev, @Timothy Leavitt and @Dmitry Maslennikov.
But IMHO zpm is overkill for this if you don't plan to deploy using registry and zpm client. Maybe just a few ObjectScript calls will help like in this Dockerfile.
HTH
Looks like the new version of the %Installer for IRIS already supports this setting.
But it might still be helpful to clear that question about the ZPM for other circunstances.
Yes, for sure, you can install any packages locally
it can be as a folder, or as file tgz, which you can get with command
-v is optional, to get more logs for debugging
Agreed, I tend to use zpm for my own projects even if I don't intend to distribute. Between declaring dependencies, simpler running of unit tests, ability to script more things with my project than just "install" - it's just generally handy.
Social networks
InterSystems resources
Log in or sign up
Log in or create a new account to continue
Log in or sign up
Log in or create a new account to continue
Log in or sign up
Log in or create a new account to continue