ProcessMessage: used to prevent a method call?

Hello,

In my server sink implementation, in the ProcessMessage() method, I need to (selectively) make sure that the call to "requestMsg.Properties["__MethodName"]" method is not carried out on the server.

Ideally, I want the server to remain oblivious that the client has even attempted to call that method, yet for the called method to return "false" on the client side (if at all possible).

So far all of my attempts resulted in exceptions thrown on the client side. Does anybody know of the proper way to implement my requirement, please

Thank you,
Victoria


Answer this question

ProcessMessage: used to prevent a method call?

  • asalcedo

    Dumitru, thank you! This solves my problem (I was setting responseMsg to null, doh...)

    Could you also tell me if there is a way of finding the return value of the invoked method in ProcessMessage, but without using reflection methodCall.methodSignature looks promising, but it seems to always contain null.

    Thank you once again.

  • Eddie C

    Did you try something like that

    public ServerProcessing ProcessMessage(IServerChannelSinkStack sinkStack,
     IMessage requestMsg,
     ITransportHeaders requestHeaders,
     Stream requestStream,
     out IMessage responseMsg,
     out ITransportHeaders responseHeaders,
     out Stream responseStream)
    {
    if(... yourcondition...)
    {
    ServerProcessing srvProc = _nextSink.ProcessMessage(sinkStack,
     requestMsg,
     requestHeaders,
     requestStream,
     out responseMsg,
     out responseHeaders,
     out responseStream);
    return srvProc;
    }
    else
    {
    MethodCall methodCall = (MethodCall)requestMsg;
    responseMsg = new ReturnMessage(false, methodCall.Args, methodCall.ArgCount, methodCall.LogicalCallContext, methodCall);
    responseHeaders = null;
    responseStream = null;
    return ServerProcessing.Complete;
    }
    }


    It should work if your remoting method is returning a bool value.
    If your method is not returning a bool value, you can return that bool value using the LogicalCallContext.


  • hye_heena

    Yes, Dumitru, thank you!
  • Kevin Dente

    You mean the return type

    ParameterInfo returnParameter = ((MethodInfo)methodCall.MethodBase).ReturnParameter;

    Of course that this call is using reflection under the hood.


  • ProcessMessage: used to prevent a method call?