예제 #1
0
        public IMessage SyncProcessMessage(IMessage msg)
        {
            CheckParameters(msg);

            // Makes the real call to the object
            if (_rp != null)
            {
                return(_rp.Invoke(msg));
            }
            else
            {
                return(RemotingServices.InternalExecuteMessage(_target, (IMethodCallMessage)msg));
            }
        }
예제 #2
0
        public override IMessage Invoke(IMessage msg)
        {
            int nbWcfExceptions = 0;
            int nbExceptions    = 0;

            while (true)
            {
                // Ensure channel is open
                if (!IsChannelUsable())
                {
                    CloseChannel();
                    OpenChannel();
                }

                // Call Channel method
                var result = _innerChannelProxy.Invoke(msg) as IMethodReturnMessage;

                // Everything ok
                if (result.Exception == null)
                {
                    return(result);
                }

                // Manage Exceptions
                if (result.Exception is CommunicationException)
                {
                    nbWcfExceptions++;

                    // WCF Communication exception (faulted channel for example)
                    if (nbWcfExceptions > NbRetriesOnWcfException)
                    {
                        return(result);
                    }

                    // Notify exception
                    if (RetryOnCommunicationException != null)
                    {
                        RetryOnCommunicationException(result.Exception as CommunicationException);
                    }
                }
                else
                {
                    nbExceptions++;

                    // Not an communication exception
                    if (nbExceptions > NbRetriesOnException)
                    {
                        return(result);
                    }

                    // Notify exception
                    if (RetryOnException != null)
                    {
                        RetryOnException(result.Exception);
                    }
                }
            }
        }
예제 #3
0
        private static void InvokeRealProxy(RealProxy realProxy, WcfInvocation wcfInvocation)
        {
            var message       = new MethodCallMessage(wcfInvocation.Method, wcfInvocation.Arguments);
            var returnMessage = (IMethodReturnMessage)realProxy.Invoke(message);

            if (returnMessage.Exception != null)
            {
                var exception = ExceptionHelper.PreserveStackTrace(returnMessage.Exception);
                throw exception;
            }
            wcfInvocation.ReturnValue = returnMessage.ReturnValue;
        }
        // Implement Invoke
        public override IMessage Invoke(IMessage reqmsg)
        {
            DBG.Info(DBG.SC, "Intermediary: Invoke: forwarding call...");

            IMessage retmsg = HandleSpecialMessages(reqmsg);

            if (retmsg != null)
            {
                return(retmsg);
            }

            return(_pxy.Invoke(reqmsg));
        }
        public override IMessage Invoke(IMessage message)
        {
            RealProxy          delegatingProxy = null;
            IMethodCallMessage msg             = message as IMethodCallMessage;

            try
            {
                delegatingProxy = serviceChannelCreator.CreateChannel();
            }
            catch (Exception e)
            {
                if (Fx.IsFatal(e))
                {
                    throw;
                }

                return(new ReturnMessage(DiagnosticUtility.ExceptionUtility.ThrowHelperError(new COMException(e.GetBaseException().Message, Marshal.GetHRForException(e.GetBaseException()))), msg));
            }

            MethodBase        typeMethod = msg.MethodBase;
            IRemotingTypeInfo typeInfo   = delegatingProxy as IRemotingTypeInfo;

            if (typeInfo == null)
            {
                throw Fx.AssertAndThrow("Type Info cannot be null");
            }
            if (typeInfo.CanCastTo(typeMethod.DeclaringType, null))
            {
                IMessage      msgReturned = delegatingProxy.Invoke(message);
                ReturnMessage returnMsg   = msgReturned as ReturnMessage;
                if ((returnMsg == null) || (returnMsg.Exception == null))
                {
                    return(msgReturned);
                }
                else
                {
                    return(new ReturnMessage(DiagnosticUtility.ExceptionUtility.ThrowHelperError(new COMException(returnMsg.Exception.GetBaseException().Message, Marshal.GetHRForException(returnMsg.Exception.GetBaseException()))), msg));
                }
            }
            else
            {
                return(new ReturnMessage(DiagnosticUtility.ExceptionUtility.ThrowHelperError(new COMException(SR.GetString(SR.OperationNotFound, typeMethod.Name), HR.DISP_E_UNKNOWNNAME)), msg));
            }
        }
예제 #6
0
        // helper to implement RemoteDispatch methods
        private String RemoteDispatchHelper(String s, out bool failed)
        {
            if (_denyRemoteDispatch)
            {
                throw new UnauthorizedAccessException(Resource.FormatString("ServicedComponentException_SecurityMapping"));
            }
            IMessage reqMsg = ComponentServices.ConvertToMessage(s, this);


            // Check to see if the method is marked as secure on the
            // server side:  If so, we need to kick it back to the caller,
            // cause they called us incorrectly.  Also verify the method
            // is not private, internal, or static.

            CheckMethodAccess(reqMsg);

            RealProxy rp = RemotingServices.GetRealProxy(this);

            DBG.Assert(rp != null, "Null RP in Invoke helper");

            IMessage retMsg = rp.Invoke(reqMsg);

            // Check for failures:
            IMethodReturnMessage mrm = retMsg as IMethodReturnMessage;

            if (mrm != null && mrm.Exception != null)
            {
                failed = true;
            }
            else
            {
                failed = false;
            }

            String sret = ComponentServices.ConvertToString(retMsg);

            return(sret);
        }
예제 #7
0
        public override IMessage Invoke(IMessage message)
        {
            RealProxy          proxy = null;
            IMethodCallMessage mcm   = message as IMethodCallMessage;

            try
            {
                proxy = this.serviceChannelCreator.CreateChannel();
            }
            catch (Exception exception)
            {
                if (Fx.IsFatal(exception))
                {
                    throw;
                }
                return(new ReturnMessage(DiagnosticUtility.ExceptionUtility.ThrowHelperError(new COMException(exception.GetBaseException().Message, Marshal.GetHRForException(exception.GetBaseException()))), mcm));
            }
            MethodBase        methodBase = mcm.MethodBase;
            IRemotingTypeInfo info       = proxy as IRemotingTypeInfo;

            if (info == null)
            {
                throw Fx.AssertAndThrow("Type Info cannot be null");
            }
            if (info.CanCastTo(methodBase.DeclaringType, null))
            {
                IMessage      message3 = proxy.Invoke(message);
                ReturnMessage message4 = message3 as ReturnMessage;
                if ((message4 != null) && (message4.Exception != null))
                {
                    return(new ReturnMessage(DiagnosticUtility.ExceptionUtility.ThrowHelperError(new COMException(message4.Exception.GetBaseException().Message, Marshal.GetHRForException(message4.Exception.GetBaseException()))), mcm));
                }
                return(message3);
            }
            return(new ReturnMessage(DiagnosticUtility.ExceptionUtility.ThrowHelperError(new COMException(System.ServiceModel.SR.GetString("OperationNotFound", new object[] { methodBase.Name }), HR.DISP_E_UNKNOWNNAME)), mcm));
        }
예제 #8
0
 public override IMessage Invoke(IMessage msg)
 {
     return(innerProxy.Invoke(msg));
 }
예제 #9
0
 public override IMessage Invoke( IMessage msg ) {
     RealProxy rp = RemotingServices.GetRealProxy( _obj );
     return rp.Invoke( msg );
 }