Question
· May 28, 2021

How would you recommend to list all REST Services in a namespace?

Hello,

First of all thank you for reading this question

Also thank you for giving an answer

We would need some help

Our objective is to spot all REST Services in a namespace

➡️ How could we detect all services with AdapterClassname  = EnsLib.HTTP.InboundAdapter , in an automatic way, in a namespace?

➡️ Thanks for your replies

We have read:

https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls...

https://docs.intersystems.com/latest/csp/docbook/Doc.View.cls?KEY=GREST_...

Discussion (5)2
Log in or sign up to continue

Here's a method that might get you close to what you want:

ClassMethod GetHostsByAdapter(pProduction As %String, pAdapterName As %String) As %List
{
        Set tPrd = ##class(Ens.Config.Production).%OpenId(pProduction)
        Return:'$ISOBJECT(tPrd) "Production does not exist!"
        Set tItems = tPrd.Items
        Set tItemCnt = tItems.Count()
        Set tHostList = ""
        Set tCnt = 1
        For i=1:1:tItemCnt
        {
            Set tItem = tItems.GetAt(i)
            If $CLASSMETHOD(tItem.ClassName,"%GetParameter","ADAPTER") = pAdapterName
            {
                Set $LIST(tHostList,tCnt) = tItem.Name
                Set tCnt = tCnt + 1
            }
        }
        Return tHostList
}

Call it with:

Set hosts=##class(<classname>).GetHostsByAdapter("<production name>","EnsLib.HTTP.InboundAdapter")

The variable hosts will contain the list (in $LIST form) of business hosts that have the adapter specified as the 2nd argument.

Thanks Jeffrey

We have placed your function in a class called "Util.FuncionesComunes"

We have tried to execute it as follows:

Set hosts=##class(Util.FuncionesComunes).GetHostsByAdapter("Produccion.ESBSSCC","EnsLib.HTTP.InboundAdapter")

It shows:

SET hosts=##class(Util.FuncionesComunes).GetHostsByAdapter("Produccion.ESBSSCC",
^
"EnsLib.HTTP.InboundAdapter")
<COMMAND>^Util.FuncionesComunes.1

When we write: "w $ZERROR" it outputs:

SET hosts=##class(Util.FuncionesComunes).GetHostsByAdapter("Produccion.ESBSSCC",
^
"EnsLib.HTTP.InboundAdapter")
<COMMAND>^Util.FuncionesComunes.1

How could we solve this?

I tested the method on my own system before posting it, so I'm not sure why you're getting the error.

Did you compile the class after saving it?

Are you certain the name of the production is spelled correctly?

Are you in the proper namespace?

EDIT: I also added a tiny bit of error checking to the original method ... note the Return statement after the line Set tPrd...

Thanks Jeffrey for your kind help, and thanks for your time.

We have wrote your method in a class called "Util.FuncionesComunes"

Namespace "ESBSSCC"

We have wrote in the terminal:

ESBSSCC 2e1>Set hosts=##class(Util.FuncionesComunes).GetHostsByAdapter("Producion.ESBSSCC","EnsLib.HTTP.InboundAdapter")
 

We observe:


SET hosts=##class(Util.FuncionesComunes).GetHostsByAdapter("Produccion.ESBSSCC",
^
"EnsLib.HTTP.InboundAdapter")
<COMMAND>^Util.FuncionesComunes.1

ESBSSCC 2e1>

Production's name is: Producion.ESBSSCC

How could we debug this to be able to execute the code and list all REST services in the current namespace?

Thanks for your help, time and replies Jeffrey

You appear to be attempting to call the method from the debugger. Type Q to return to the normal Cache/IRIS prompt and try again ... let me know what happens.

Being in the debugger shouldn't be a problem unless you have the Secure Debug Shell enabled. There are a lot of things you can't do from the debugger when that's enabled, and one of them is using the SET command.