Yone Moreno · May 28

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


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:

2 0 5 90
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",

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

SET hosts=##class(Util.FuncionesComunes).GetHostsByAdapter("Produccion.ESBSSCC",

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",


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.