Customizing Callbacks of a Web Service
You can customize the behavior of an InterSystems IRIS® data platform web service by overriding its callback methods:
Called when the web service receives a request message, if there is no security error; this callback is not invoked in the case of a security error. The system invokes this callback after performing security processing, after checking the envelope for errors, and after processing the actions specified in the WS-Addressing header (if any). This callback is useful for tasks such as logging raw SOAP requests.
This method has the following signature:
Method OnRequestMessage(mode As %String, action As %String, request As %Stream.Object)
Where:
-
mode specifies the type of SOAP request. This is either "SOAP" or "binary".
-
action contains the value of SOAPAction header.
-
request contains the SOAP request message in a stream.
This method can use the object %request, which is an instance of %CSP.SessionOpens in a new tab. In this object:
-
The Content property contains the raw request message.
-
The NextMimeData() instance method enables you to retrieve individual MIME parts (if this is a MIME SOAP request).
This method can also use properties of the web service instance. The following properties are set during initialization:
-
The ImportHandler property contains the DOM for parsed SOAP request message.
-
The SecurityIn property contains the WS-Security header element. For details, see Securing Web Services.
-
The SecurityNamespace property contains the namespace for the WS-Security header element.
-
The SoapFault property is set if SOAP fault has been generated.
To return a fault within OnRequestMessage(), set the SoapFault property. Do not call the ReturnFault() method.
Called just before a web method is executed; does nothing by default. This method takes no arguments and cannot return a value. This method therefore cannot change the execution of the web service except by returning a SOAP fault in the same way that a web method would do.
This method can use %request, %session, and the web service properties. Note that the MsgClass property of the web service is the message descriptor class that contains the web method arguments.
Called just after a web method is executed; does nothing by default. This method takes no arguments and cannot return a value. This method therefore cannot change the execution or return value of the web method. You customize this method primarily to clean up required structures created by OnPreWebMethod().