Skip to main content

Invoking a Business Service Directly

Invoking a Business Service Directly

There are times when you want to invoke a business service directly, from a job that has been created by some other mechanism, such as a language binding, CSP pages, SOAP, or a routine invoked from the operating system level. You can do so only if the value of the ADAPTER class parameter is null; this type of business service is called an adapterless business service.

For a business service to work, you must create an instance of the business service class. You cannot create this instance by calling the %New() method. Instead, you must use the method CreateBusinessService() of Ens.DirectorOpens in a new tab. For example:

  Set tSC = ##class(Ens.Director).CreateBusinessService("MyService",.tService)

A production does not allocate a job for this business service at production startup; it assumes a Pool Size setting of 0.

The CreateBusinessService() method does the following:

  1. It makes sure that a production is running and that the production defines the given business service.

  2. It makes sure that the given business service is currently enabled.

  3. It resolves the configuration name of the business service and instantiates the correct business service object using the correct configuration values (a production may define many business services using the same business service class but with different names and settings).

If the CreateBusinessService() method succeeds, it returns, by reference, an instance of the business service class. You can then invoke its ProcessInput() method directly. You must provide the ProcessInput() method with an instance of the input object it expects. For example:

If ($IsObject(tService)) {
  Set input = ##class(MyObject).%New()
  Set input.Value = 22
  Set tSC = tService.ProcessInput(input,.output)
}

Ens.DirectorOpens in a new tab provides many class methods, including many intended for use only by the InterSystems IRIS internal framework. InterSystems recommends that you use only the Ens.DirectorOpens in a new tab methods documented here, and only as documented.

FeedbackOpens in a new tab