コード例 #1
0
        void InitializeCallContextCore(MessageRpc rpc)
        {
            IClientChannel channel = rpc.Channel.Proxy as IClientChannel;
            int            offset  = Parent.CallContextCorrelationOffset;

            try
            {
                for (int i = 0; i < rpc.Operation.CallContextInitializers.Length; i++)
                {
                    ICallContextInitializer initializer = CallContextInitializers[i];
                    rpc.Correlation[offset + i] = initializer.BeforeInvoke(rpc.InstanceContext, channel, rpc.Request);
                }
            }
            catch (Exception e)
            {
                if (Fx.IsFatal(e))
                {
                    throw;
                }
                if (ErrorBehavior.ShouldRethrowExceptionAsIs(e))
                {
                    throw;
                }
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperCallback(e);
            }
        }
コード例 #2
0
        //internal bool TransactionAutoComplete
        //{
        //    get { return this.transactionAutoComplete; }
        //}

        //internal bool TransactionRequired
        //{
        //    get { return this.transactionRequired; }
        //}

        //internal bool IsInsideTransactedReceiveScope
        //{
        //    get { return this.isInsideTransactedReceiveScope; }
        //}

        void DeserializeInputs(MessageRpc rpc)
        {
            //bool success = false;
            try
            {
                try
                {
                    rpc.InputParameters = Invoker.AllocateInputs();
                }
                catch (Exception e)
                {
                    if (Fx.IsFatal(e))
                    {
                        throw;
                    }
                    if (ErrorBehavior.ShouldRethrowExceptionAsIs(e))
                    {
                        throw;
                    }
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperCallback(e);
                }
                try
                {
                    // If the field is true, then this operation is to be invoked at the time the service
                    // channel is opened. The incoming message is created at ChannelHandler level with no
                    // content, so we don't need to deserialize the message.
                    if (!isSessionOpenNotificationEnabled)
                    {
                        if (deserializeRequest)
                        {
                            //if (TD.DispatchFormatterDeserializeRequestStartIsEnabled())
                            //{
                            //    TD.DispatchFormatterDeserializeRequestStart(rpc.EventTraceActivity);
                            //}

                            Formatter.DeserializeRequest(rpc.Request, rpc.InputParameters);

                            //if (TD.DispatchFormatterDeserializeRequestStopIsEnabled())
                            //{
                            //    TD.DispatchFormatterDeserializeRequestStop(rpc.EventTraceActivity);
                            //}
                        }
                        else
                        {
                            rpc.InputParameters[0] = rpc.Request;
                        }
                    }

                    //success = true;
                }
                catch (Exception e)
                {
                    if (Fx.IsFatal(e))
                    {
                        throw;
                    }
                    if (ErrorBehavior.ShouldRethrowExceptionAsIs(e))
                    {
                        throw;
                    }
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperCallback(e);
                }
            }
            finally
            {
                rpc.DidDeserializeRequestBody = (rpc.Request.State != MessageState.Created);

                //if (!success && MessageLogger.LoggingEnabled)
                //{
                //    MessageLogger.LogMessage(rpc.Request, MessageLoggingSource.Malformed);
                //}
            }
        }
コード例 #3
0
        void SerializeOutputs(ref MessageRpc rpc)
        {
            if (!IsOneWay && parent.EnableFaults)
            {
                Message reply;
                if (serializeReply)
                {
                    try
                    {
                        //if (TD.DispatchFormatterSerializeReplyStartIsEnabled())
                        //{
                        //    TD.DispatchFormatterSerializeReplyStart(rpc.EventTraceActivity);
                        //}

                        reply = Formatter.SerializeReply(rpc.RequestVersion, rpc.OutputParameters, rpc.ReturnParameter);

                        //if (TD.DispatchFormatterSerializeReplyStopIsEnabled())
                        //{
                        //    TD.DispatchFormatterSerializeReplyStop(rpc.EventTraceActivity);
                        //}
                    }
                    catch (Exception e)
                    {
                        if (Fx.IsFatal(e))
                        {
                            throw;
                        }
                        if (ErrorBehavior.ShouldRethrowExceptionAsIs(e))
                        {
                            throw;
                        }
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperCallback(e);
                    }

                    if (reply == null)
                    {
                        string message = SR.Format(SR.SFxNullReplyFromFormatter2, Formatter.GetType().ToString(), (name ?? ""));
                        ErrorBehavior.ThrowAndCatch(new InvalidOperationException(message));
                    }
                }
                else
                {
                    if ((rpc.ReturnParameter == null) && (rpc.OperationContext.RequestContext != null))
                    {
                        string message = SR.Format(SR.SFxDispatchRuntimeMessageCannotBeNull, name);
                        ErrorBehavior.ThrowAndCatch(new InvalidOperationException(message));
                    }

                    reply = (Message)rpc.ReturnParameter;

                    if ((reply != null) && (!ProxyOperationRuntime.IsValidAction(reply, ReplyAction)))
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.SFxInvalidReplyAction, Name, reply.Headers.Action ?? "{NULL}", ReplyAction)));
                    }
                }

                //if (DiagnosticUtility.ShouldUseActivity && rpc.Activity != null && reply != null)
                //{
                //    TraceUtility.SetActivity(reply, rpc.Activity);
                //    if (TraceUtility.ShouldPropagateActivity)
                //    {
                //        TraceUtility.AddActivityHeader(reply);
                //    }
                //}
                //else if (TraceUtility.ShouldPropagateActivity && reply != null && rpc.ResponseActivityId != Guid.Empty)
                //{
                //    ActivityIdHeader header = new ActivityIdHeader(rpc.ResponseActivityId);
                //    header.AddTo(reply);
                //}

                //rely on the property set during the message receive to correlate the trace
                //if (TraceUtility.MessageFlowTracingOnly)
                //{
                //    //Guard against MEX scenarios where the message is closed by now
                //    if (null != rpc.OperationContext.IncomingMessage && MessageState.Closed != rpc.OperationContext.IncomingMessage.State)
                //    {
                //        FxTrace.Trace.SetAndTraceTransfer(TraceUtility.GetReceivedActivityId(rpc.OperationContext), true);
                //    }
                //    else
                //    {
                //        if (rpc.ResponseActivityId != Guid.Empty)
                //        {
                //            FxTrace.Trace.SetAndTraceTransfer(rpc.ResponseActivityId, true);
                //        }
                //    }
                //}

                // Add the ImpersonateOnSerializingReplyMessageProperty on the reply message iff
                // a. reply message is not null.
                // b. Impersonation is enabled on serializing Reply

                //if (reply != null && this.parent.IsImpersonationEnabledOnSerializingReply)
                //{
                //    bool shouldImpersonate = this.parent.SecurityImpersonation != null && this.parent.SecurityImpersonation.IsImpersonationEnabledOnCurrentOperation(ref rpc);
                //    if (shouldImpersonate)
                //    {
                //        reply.Properties.Add(ImpersonateOnSerializingReplyMessageProperty.Name, new ImpersonateOnSerializingReplyMessageProperty(ref rpc));
                //        reply = new ImpersonatingMessage(reply);
                //    }
                //}

                //if (MessageLogger.LoggingEnabled && null != reply)
                //{
                //    MessageLogger.LogMessage(ref reply, MessageLoggingSource.ServiceLevelSendReply | MessageLoggingSource.LastChance);
                //}
                rpc.Reply = reply;
            }
        }