Skip to main content

Older Ensemble Web Service Variation

In previous releases, an Ensemble web method could not directly call SendRequestSync(), SendRequestAsync(), or SendDeferredResponse(). An alternative approach was needed. This appendix provides the details, for the benefit of anyone who is maintaining code that uses this alternative approach.

Overview

In previous releases, an Ensemble web method could not directly call SendRequestSync(), SendRequestAsync(), or SendDeferredResponse(). Instead, there were two requirements for an Ensemble web service, in addition to the requirements discussed earlier in this book:

  • Each web method had to invoke the ProcessInput() method as appropriate, passing to it the appropriate request Ensemble message and receiving an Ensemble response message.

  • The web service class had to define the OnProcessInput() callback method. In this method, you would call SendRequestSync(), SendRequestAsync(), or SendDeferredResponse().

The following figure shows the overall flow of request messages in this scenario:

generated description: web service

Implementing the OnProcessInput() Method

The OnProcessInput() method has the following signature:

Method OnProcessInput(pInput As %RegisteredObject,
                      ByRef pOutput As %RegisteredObject,
                      ByRef pHint As %String) As %Status

Here:

  1. pInput is the Ensemble request message that you are sending.

  2. pOutput is the Ensemble response message that is sent in return.

  3. pHint is an optional string that you can use to decide how to handle the Ensemble request; see the subsection “Using the pHint Argument.”

The following shows an example:

Method OnProcessInput(pInput As %RegisteredObject, ByRef pOutput As %RegisteredObject) As %Status
{
    set sc= ..SendRequestSync("Lookup",pInput,.pOutput)
    Quit sc
}

Using the pHint Argument

If a web service defined multiple methods, and you wanted to send them to different destinations within the production, you used the optional hint argument of the ProcessInput() and OnProcessInput() methods, as follows:

  1. When you invoke ProcessInput(), you used a value for the hint argument to indicate which web method is making this call. For example:

    Method GetCustomerInfo(ID As %Numeric) As ESOAP.SOAPResponse [ WebMethod ]
    {
        //create Ensemble request message with given ID
        set request=##class(ESOAP.CustomerRequest).%New()
        set request.CustomerID=ID
    
        //send Ensemble request message
        //ProcessInput() calls OnProcessInput(), which actually
        //sends the message
        set sc=..ProcessInput(request,.response,"GetCustomerInfo")
    ...
    
        quit soapresponse
    }
    
    
  2. Within OnProcessInput(), you used the hint argument to determine the flow. For example:

    Method OnProcessInputAlt(pInput As %RegisteredObject,
    ByRef pOutput As %RegisteredObject, pHint As %String) As %Status
    {
        if pHint="GetCustomerInfo"{
            set sc= ..SendRequestSync("GetCustomerInfoBO",pInput,.pOutput)
            }
        elseif pHint="GetStoreInfo" {
                set sc= ..SendRequestSync("GetStoreInfoBO",pInput,.pOutput)
        }
        Quit sc
    }
FeedbackOpens in a new tab