20.11 Different Types of SRVROUTINE

The definition and command used to invoke a SRVROUTINE in a Server Module have a common format and look something like:

Define_Com Class(#MyServerRoutine.GetData) Name(#GetData)

# GetData.ExecuteAsync EmployeeID(#Empno) EmployeeDetails(#MyEmployee) status(#io$sts)

or

# GetData.Execute(#EmployeeID #MyEmployee #io$sts)

However, when you look more closely at the actual SRVROUTINE definitions there are three different classes of SRVROUTINE and it is important to understand the difference when you are coding a call to the routine and handling responses from the routine. What distinguishes them is type of data exchanged and how the request is processed. When you examine the methods, events and properties supported by the explicit DEFINE_COM (use F2) you will see the relationship more clearly.

Data Request

The most common type of SRVROUTINE call is a Data Request. A Data Request processes a request from the client, optionally accompanied by data, and fires a status event on completion, as well as optionally returning data in JSON format to the client.

Characteristics of a Data Request:

  • Data can be passed into and received from the SRVROUTINE as a single field, a group of fields or a list of fields
  • Synchronous and Asynchronous invocation (that is, execute and executeasync methods) are supported
  • Completion can be verified using the Completed and Failed events.
  • Web Page Request

    Request to transfer to another Web Page.

    Characteristics of a Web Page Request

  • Only Synchronous execution is supported (that is, executeasync method is not supported)
  • Data mapped as *input/*both can be processed in the SRVROUTINE before transferring to the requested Web Page
  • Data mapped as *output/*both is passed to requested web page.
  • Resource Request

    A Resource Request is used to a return file, such as an image or PDF from the database or application server. This is not commonly used as files can be accessed directly from the Web Server if they are stored there instead.

    Characteristics of a Response Resource:

  • Data can be passed into the SRVROUTINE as a single field, a group of fields or a list of fields but is not returned from the SRVROUTINE (i.e. *input/*both mappings are supported for input only, *output mappings are not supported)
  • Only Synchronous execution is supported (i.e. executeasync method is not supported)
  • A single response object (PRIM_CLRC) is the only information returned from the routine