Skip to main content
************* PRERELEASE CONTENT *************
Previous sectionNext section

Older Web Service Variation

In previous releases, an InterSystems IRIS® 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 InterSystems IRIS web method could not directly call SendRequestSync(), SendRequestAsync(), or SendDeferredResponse(). Instead, there were two requirements for a production 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 production message and receiving a 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
Copy code to clipboard

Here:

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

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

  3. pHint is an optional string that you can use to decide how to handle the InterSystems IRIS 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
}
Copy code to clipboard

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 request message with given ID
        set request=##class(ESOAP.CustomerRequest).%New()
        set request.CustomerID=ID
    
        //send request message
        //ProcessInput() calls OnProcessInput(), which actually
        //sends the message
        set sc=..ProcessInput(request,.response,"GetCustomerInfo")
    ...
    
        quit soapresponse
    }
    
    Copy code to clipboard
  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
    }
    Copy code to clipboard