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 topic 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 basic requirements:
-
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:
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:
-
pInput is the request message that you are sending.
-
pOutput is the response message that is sent in return.
-
pHint is an optional string that you can use to decide how to handle the InterSystems IRIS request; see 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:
-
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 }
-
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 }