I'm just learning about WCF WebMethods, and have started to digest the code to plug in the IParameterInspector
interface for parameter validation.
Can someone please tell me in the most basic terms what the purpose is of the return object in the BeforeCall()
function? For example:
Public Function BeforeCall(operationName As String, inputs() As Object) **As Object** Implements IParameterInspector.BeforeCall
End Function
Through basic testing I realise that I can return an object from BeforeCall()
that then becomes available within AfterCall()
correlationState
parameter.
I assume that this value doesn't get returned anywhere else from the consuming code?
Can someone please provide some basic examples of why programmers might need to utilize this please?
You are right, the return value is just a correlationState as msdn documentation states.
Return Value
Type: System.Object
The correlation state that is returned as the correlationState parameter in AfterCall. Return null if you do not intend to use correlation state.
And, as described, it is only used as a correlation state strictly between the BeforeCall()
and AfterCall()
.
And, about the basic example, you can use it to implement your own correlation business logic there. For example you might want to retrieve in the after call the input parameters, that you previously stored in a persistent state and based on them perform some custom logic (logging or actual alteration of output values).