internal void AfterReceiveReply(ref ProxyRpc rpc) { int messageInspectorCorrelationOffset = this.MessageInspectorCorrelationOffset; try { for (int i = 0; i < this.messageInspectors.Length; i++) { this.messageInspectors[i].AfterReceiveReply(ref rpc.Reply, rpc.Correlation[messageInspectorCorrelationOffset + i]); if (TD.ClientMessageInspectorAfterReceiveInvokedIsEnabled()) { TD.ClientMessageInspectorAfterReceiveInvoked(this.messageInspectors[i].GetType().FullName); } } } catch (Exception exception) { if (Fx.IsFatal(exception)) { throw; } if (ErrorBehavior.ShouldRethrowClientSideExceptionAsIs(exception)) { throw; } throw DiagnosticUtility.ExceptionUtility.ThrowHelperCallback(exception); } }
internal void BeforeSendRequest(ref ProxyRpc rpc) { int messageInspectorCorrelationOffset = this.MessageInspectorCorrelationOffset; try { for (int i = 0; i < this.messageInspectors.Length; i++) { rpc.Correlation[messageInspectorCorrelationOffset + i] = this.messageInspectors[i].BeforeSendRequest(ref rpc.Request, (IClientChannel) rpc.Channel.Proxy); if (TD.ClientMessageInspectorBeforeSendInvokedIsEnabled()) { TD.ClientMessageInspectorBeforeSendInvoked(this.messageInspectors[i].GetType().FullName); } } } catch (Exception exception) { if (Fx.IsFatal(exception)) { throw; } if (ErrorBehavior.ShouldRethrowClientSideExceptionAsIs(exception)) { throw; } throw DiagnosticUtility.ExceptionUtility.ThrowHelperCallback(exception); } if (this.addTransactionFlowProperties) { SendTransaction(ref rpc); } }
internal void AfterReceiveReply(ref ProxyRpc rpc) { int offset = this.MessageInspectorCorrelationOffset; try { for (int i = 0; i < _messageInspectors.Length; i++) { _messageInspectors[i].AfterReceiveReply(ref rpc.Reply, rpc.Correlation[offset + i]); if (WcfEventSource.Instance.ClientMessageInspectorAfterReceiveInvokedIsEnabled()) { WcfEventSource.Instance.ClientMessageInspectorAfterReceiveInvoked(rpc.EventTraceActivity, _messageInspectors[i].GetType().FullName); } } } catch (Exception e) { if (Fx.IsFatal(e)) { throw; } if (ErrorBehavior.ShouldRethrowClientSideExceptionAsIs(e)) { throw; } throw DiagnosticUtility.ExceptionUtility.ThrowHelperCallback(e); } }
internal static void AfterReply(ref ProxyRpc rpc) { if (rpc.Operation.IsTerminating && rpc.Channel.HasSession) { IChannel channel = rpc.Channel.Binder.Channel; rpc.Channel.Close(rpc.TimeoutHelper.RemainingTime()); } }
internal void BeforeRequest(ref ProxyRpc rpc) { int offset = _parent.ParameterInspectorCorrelationOffset; try { for (int i = 0; i < _parameterInspectors.Length; i++) { rpc.Correlation[offset + i] = _parameterInspectors[i].BeforeCall(_name, rpc.InputParameters); if (WcfEventSource.Instance.ClientParameterInspectorBeforeCallInvokedIsEnabled()) { WcfEventSource.Instance.ClientParameterInspectorBeforeCallInvoked(rpc.EventTraceActivity, _parameterInspectors[i].GetType().FullName); } } } catch (Exception e) { if (Fx.IsFatal(e)) { throw; } if (ErrorBehavior.ShouldRethrowClientSideExceptionAsIs(e)) { throw; } throw DiagnosticUtility.ExceptionUtility.ThrowHelperCallback(e); } if (_serializeRequest) { if (WcfEventSource.Instance.ClientFormatterSerializeRequestStartIsEnabled()) { WcfEventSource.Instance.ClientFormatterSerializeRequestStart(rpc.EventTraceActivity); } rpc.Request = _formatter.SerializeRequest(rpc.MessageVersion, rpc.InputParameters); if (WcfEventSource.Instance.ClientFormatterSerializeRequestStopIsEnabled()) { WcfEventSource.Instance.ClientFormatterSerializeRequestStop(rpc.EventTraceActivity); } } else { if (rpc.InputParameters[0] == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(string.Format(SRServiceModel.SFxProxyRuntimeMessageCannotBeNull, _name))); } rpc.Request = (Message)rpc.InputParameters[0]; if (!IsValidAction(rpc.Request, Action)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(string.Format(SRServiceModel.SFxInvalidRequestAction, this.Name, rpc.Request.Headers.Action ?? "{NULL}", this.Action))); } } }
internal void BeforeSendRequest(ref ProxyRpc rpc) { int offset = this.MessageInspectorCorrelationOffset; try { bool outputTiming = DS.MessageInspectorIsEnabled(); Stopwatch sw = null; if (outputTiming) { sw = new Stopwatch(); } for (int i = 0; i < this.messageInspectors.Length; i++) { if (outputTiming) { sw.Restart(); } rpc.Correlation[offset + i] = this.messageInspectors[i].BeforeSendRequest(ref rpc.Request, (IClientChannel)rpc.Channel.Proxy); if (outputTiming) { DS.ClientMessageInspectorBeforeSend(this.messageInspectors[i].GetType(), sw.Elapsed); } if (TD.ClientMessageInspectorBeforeSendInvokedIsEnabled()) { TD.ClientMessageInspectorBeforeSendInvoked(rpc.EventTraceActivity, this.messageInspectors[i].GetType().FullName); } } } catch (Exception e) { if (Fx.IsFatal(e)) { throw; } if (ErrorBehavior.ShouldRethrowClientSideExceptionAsIs(e)) { throw; } throw DiagnosticUtility.ExceptionUtility.ThrowHelperCallback(e); } if (this.addTransactionFlowProperties) { SendTransaction(ref rpc); } }
internal void AfterReply(ref ProxyRpc rpc) { if (!this.isOneWay) { System.ServiceModel.Channels.Message reply = rpc.Reply; if (this.deserializeReply) { rpc.ReturnValue = this.formatter.DeserializeReply(reply, rpc.OutputParameters); } else { rpc.ReturnValue = reply; } int parameterInspectorCorrelationOffset = this.parent.ParameterInspectorCorrelationOffset; try { for (int i = this.parameterInspectors.Length - 1; i >= 0; i--) { this.parameterInspectors[i].AfterCall(this.name, rpc.OutputParameters, rpc.ReturnValue, rpc.Correlation[parameterInspectorCorrelationOffset + i]); if (TD.ClientParameterInspectorAfterCallInvokedIsEnabled()) { TD.ClientParameterInspectorAfterCallInvoked(this.parameterInspectors[i].GetType().FullName); } } } catch (Exception exception) { if (Fx.IsFatal(exception)) { throw; } if (System.ServiceModel.Dispatcher.ErrorBehavior.ShouldRethrowClientSideExceptionAsIs(exception)) { throw; } throw DiagnosticUtility.ExceptionUtility.ThrowHelperCallback(exception); } if (this.parent.ValidateMustUnderstand) { Collection <MessageHeaderInfo> headersNotUnderstood = reply.Headers.GetHeadersNotUnderstood(); if ((headersNotUnderstood != null) && (headersNotUnderstood.Count > 0)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ProtocolException(System.ServiceModel.SR.GetString("SFxHeaderNotUnderstood", new object[] { headersNotUnderstood[0].Name, headersNotUnderstood[0].Namespace }))); } } } }
internal void BeforeRequest(ref ProxyRpc rpc) { int parameterInspectorCorrelationOffset = this.parent.ParameterInspectorCorrelationOffset; try { for (int i = 0; i < this.parameterInspectors.Length; i++) { rpc.Correlation[parameterInspectorCorrelationOffset + i] = this.parameterInspectors[i].BeforeCall(this.name, rpc.InputParameters); if (TD.ClientParameterInspectorBeforeCallInvokedIsEnabled()) { TD.ClientParameterInspectorBeforeCallInvoked(this.parameterInspectors[i].GetType().FullName); } } } catch (Exception exception) { if (Fx.IsFatal(exception)) { throw; } if (System.ServiceModel.Dispatcher.ErrorBehavior.ShouldRethrowClientSideExceptionAsIs(exception)) { throw; } throw DiagnosticUtility.ExceptionUtility.ThrowHelperCallback(exception); } if (this.serializeRequest) { rpc.Request = this.formatter.SerializeRequest(rpc.MessageVersion, rpc.InputParameters); } else { if (rpc.InputParameters[0] == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxProxyRuntimeMessageCannotBeNull", new object[] { this.name }))); } rpc.Request = (System.ServiceModel.Channels.Message)rpc.InputParameters[0]; if (!IsValidAction(rpc.Request, this.Action)) { object[] args = new object[] { this.Name, rpc.Request.Headers.Action ?? "{NULL}", this.Action }; throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxInvalidRequestAction", args))); } } }
internal void AfterReceiveReply(ref ProxyRpc rpc) { int offset = this.MessageInspectorCorrelationOffset; bool outputTiming = DS.MessageInspectorIsEnabled(); Stopwatch sw = null; if (outputTiming) { sw = new Stopwatch(); } try { for (int i = 0; i < this.messageInspectors.Length; i++) { if (outputTiming) { sw.Restart(); } this.messageInspectors[i].AfterReceiveReply(ref rpc.Reply, rpc.Correlation[offset + i]); if (outputTiming) { DS.ClientMessageInspectorAfterReceive(this.messageInspectors[i].GetType(), sw.Elapsed); } if (TD.ClientMessageInspectorAfterReceiveInvokedIsEnabled()) { TD.ClientMessageInspectorAfterReceiveInvoked(rpc.EventTraceActivity, this.messageInspectors[i].GetType().FullName); } } } catch (Exception e) { if (Fx.IsFatal(e)) { throw; } if (ErrorBehavior.ShouldRethrowClientSideExceptionAsIs(e)) { throw; } throw DiagnosticUtility.ExceptionUtility.ThrowHelperCallback(e); } }
internal void BeforeRequest(ref ProxyRpc rpc) { int offset = _parent.ParameterInspectorCorrelationOffset; try { for (int i = 0; i < _parameterInspectors.Length; i++) { rpc.Correlation[offset + i] = _parameterInspectors[i].BeforeCall(_name, rpc.InputParameters); if (TD.ClientParameterInspectorBeforeCallInvokedIsEnabled()) { TD.ClientParameterInspectorBeforeCallInvoked(rpc.EventTraceActivity, _parameterInspectors[i].GetType().FullName); } } } catch (Exception e) { if (Fx.IsFatal(e)) { throw; } if (ErrorBehavior.ShouldRethrowClientSideExceptionAsIs(e)) { throw; } throw DiagnosticUtility.ExceptionUtility.ThrowHelperCallback(e); } if (_serializeRequest) { if (TD.ClientFormatterSerializeRequestStartIsEnabled()) { TD.ClientFormatterSerializeRequestStart(rpc.EventTraceActivity); } rpc.Request = _formatter.SerializeRequest(rpc.MessageVersion, rpc.InputParameters); if (TD.ClientFormatterSerializeRequestStopIsEnabled()) { TD.ClientFormatterSerializeRequestStop(rpc.EventTraceActivity); } } else { if (rpc.InputParameters[0] == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.SFxProxyRuntimeMessageCannotBeNull, _name))); } rpc.Request = (Message)rpc.InputParameters[0]; if (!IsValidAction(rpc.Request, Action)) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.SFxInvalidRequestAction, this.Name, rpc.Request.Headers.Action ?? "{NULL}", this.Action))); } }
internal void AfterReply(ref ProxyRpc rpc) { if (!_isOneWay) { Message reply = rpc.Reply; if (_deserializeReply) { if (WcfEventSource.Instance.ClientFormatterDeserializeReplyStartIsEnabled()) { WcfEventSource.Instance.ClientFormatterDeserializeReplyStart(rpc.EventTraceActivity); } rpc.ReturnValue = _formatter.DeserializeReply(reply, rpc.OutputParameters); if (WcfEventSource.Instance.ClientFormatterDeserializeReplyStopIsEnabled()) { WcfEventSource.Instance.ClientFormatterDeserializeReplyStop(rpc.EventTraceActivity); } } else { rpc.ReturnValue = reply; } int offset = _parent.ParameterInspectorCorrelationOffset; try { for (int i = _parameterInspectors.Length - 1; i >= 0; i--) { _parameterInspectors[i].AfterCall(_name, rpc.OutputParameters, rpc.ReturnValue, rpc.Correlation[offset + i]); if (WcfEventSource.Instance.ClientParameterInspectorAfterCallInvokedIsEnabled()) { WcfEventSource.Instance.ClientParameterInspectorAfterCallInvoked(rpc.EventTraceActivity, _parameterInspectors[i].GetType().FullName); } } } catch (Exception e) { if (Fx.IsFatal(e)) { throw; } if (ErrorBehavior.ShouldRethrowClientSideExceptionAsIs(e)) { throw; } throw DiagnosticUtility.ExceptionUtility.ThrowHelperCallback(e); } if (_parent.ValidateMustUnderstand) { Collection <MessageHeaderInfo> headersNotUnderstood = reply.Headers.GetHeadersNotUnderstood(); if (headersNotUnderstood != null && headersNotUnderstood.Count > 0) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ProtocolException(SR.Format(SR.SFxHeaderNotUnderstood, headersNotUnderstood[0].Name, headersNotUnderstood[0].Namespace))); } } } }
internal void AfterReply(ref ProxyRpc rpc) { if (!_isOneWay) { Message reply = rpc.Reply; if (_deserializeReply) { if (TD.ClientFormatterDeserializeReplyStartIsEnabled()) { TD.ClientFormatterDeserializeReplyStart(rpc.EventTraceActivity); } rpc.ReturnValue = _formatter.DeserializeReply(reply, rpc.OutputParameters); if (TD.ClientFormatterDeserializeReplyStopIsEnabled()) { TD.ClientFormatterDeserializeReplyStop(rpc.EventTraceActivity); } } else { rpc.ReturnValue = reply; } int offset = _parent.ParameterInspectorCorrelationOffset; try { for (int i = _parameterInspectors.Length - 1; i >= 0; i--) { _parameterInspectors[i].AfterCall(_name, rpc.OutputParameters, rpc.ReturnValue, rpc.Correlation[offset + i]); if (TD.ClientParameterInspectorAfterCallInvokedIsEnabled()) { TD.ClientParameterInspectorAfterCallInvoked(rpc.EventTraceActivity, _parameterInspectors[i].GetType().FullName); } } } catch (Exception e) { if (Fx.IsFatal(e)) { throw; } if (ErrorBehavior.ShouldRethrowClientSideExceptionAsIs(e)) { throw; } throw DiagnosticUtility.ExceptionUtility.ThrowHelperCallback(e); } if (_parent.ValidateMustUnderstand) { Collection<MessageHeaderInfo> headersNotUnderstood = reply.Headers.GetHeadersNotUnderstood(); if (headersNotUnderstood != null && headersNotUnderstood.Count > 0) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ProtocolException(SR.Format(SR.SFxHeaderNotUnderstood, headersNotUnderstood[0].Name, headersNotUnderstood[0].Namespace))); } } } }
internal void BeforeRequest(ref ProxyRpc rpc) { int offset = this.parent.ParameterInspectorCorrelationOffset; try { bool outputTiming = DS.ParameterInspectorIsEnabled(); Stopwatch sw = null; if (outputTiming) { sw = new Stopwatch(); } for (int i = 0; i < parameterInspectors.Length; i++) { if (outputTiming) { sw.Restart(); } rpc.Correlation[offset + i] = this.parameterInspectors[i].BeforeCall(this.name, rpc.InputParameters); if (outputTiming) { DS.ParameterInspectorBefore(this.parameterInspectors[i].GetType(), sw.Elapsed); } if (TD.ClientParameterInspectorBeforeCallInvokedIsEnabled()) { TD.ClientParameterInspectorBeforeCallInvoked(rpc.EventTraceActivity, this.parameterInspectors[i].GetType().FullName); } } } catch (Exception e) { if (Fx.IsFatal(e)) { throw; } if (ErrorBehavior.ShouldRethrowClientSideExceptionAsIs(e)) { throw; } throw DiagnosticUtility.ExceptionUtility.ThrowHelperCallback(e); } if (this.serializeRequest) { if (TD.ClientFormatterSerializeRequestStartIsEnabled()) { TD.ClientFormatterSerializeRequestStart(rpc.EventTraceActivity); } bool outputTiming = DS.MessageFormatterIsEnabled(); Stopwatch sw = null; if (outputTiming) { sw = Stopwatch.StartNew(); } rpc.Request = this.formatter.SerializeRequest(rpc.MessageVersion, rpc.InputParameters); if (outputTiming) { DS.ClientMessageFormatterSerialize(this.formatter.GetType(), sw.Elapsed); } if (TD.ClientFormatterSerializeRequestStopIsEnabled()) { TD.ClientFormatterSerializeRequestStop(rpc.EventTraceActivity); } } else { if (rpc.InputParameters[0] == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.SFxProxyRuntimeMessageCannotBeNull, this.name))); } rpc.Request = (Message)rpc.InputParameters[0]; if (!IsValidAction(rpc.Request, Action)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.SFxInvalidRequestAction, this.Name, rpc.Request.Headers.Action ?? "{NULL}", this.Action))); } } }
internal void AfterReply(ref ProxyRpc rpc) { if (!this.isOneWay) { Message reply = rpc.Reply; if (this.deserializeReply) { if (TD.ClientFormatterDeserializeReplyStartIsEnabled()) { TD.ClientFormatterDeserializeReplyStart(rpc.EventTraceActivity); } bool outputTiming = DS.MessageFormatterIsEnabled(); Stopwatch sw = null; if (outputTiming) { sw = Stopwatch.StartNew(); } rpc.ReturnValue = this.formatter.DeserializeReply(reply, rpc.OutputParameters); if (outputTiming) { DS.ClientMessageFormatterDeserialize(this.formatter.GetType(), sw.Elapsed); } if (TD.ClientFormatterDeserializeReplyStopIsEnabled()) { TD.ClientFormatterDeserializeReplyStop(rpc.EventTraceActivity); } } else { rpc.ReturnValue = reply; } int offset = this.parent.ParameterInspectorCorrelationOffset; try { bool outputTiming = DS.ParameterInspectorIsEnabled(); Stopwatch sw = null; if (outputTiming) { sw = new Stopwatch(); } for (int i = parameterInspectors.Length - 1; i >= 0; i--) { if (outputTiming) { sw.Restart(); } this.parameterInspectors[i].AfterCall(this.name, rpc.OutputParameters, rpc.ReturnValue, rpc.Correlation[offset + i]); if (outputTiming) { DS.ParameterInspectorAfter(this.parameterInspectors[i].GetType(), sw.Elapsed); } if (TD.ClientParameterInspectorAfterCallInvokedIsEnabled()) { TD.ClientParameterInspectorAfterCallInvoked(rpc.EventTraceActivity, this.parameterInspectors[i].GetType().FullName); } } } catch (Exception e) { if (Fx.IsFatal(e)) { throw; } if (ErrorBehavior.ShouldRethrowClientSideExceptionAsIs(e)) { throw; } throw DiagnosticUtility.ExceptionUtility.ThrowHelperCallback(e); } if (parent.ValidateMustUnderstand) { Collection <MessageHeaderInfo> headersNotUnderstood = reply.Headers.GetHeadersNotUnderstood(); if (headersNotUnderstood != null && headersNotUnderstood.Count > 0) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ProtocolException(SR.GetString(SR.SFxHeaderNotUnderstood, headersNotUnderstood[0].Name, headersNotUnderstood[0].Namespace))); } } } }
private static void SendTransaction(ref ProxyRpc rpc) { TransactionFlowProperty.Set(Transaction.Current, rpc.Request); }
private static void SendTransaction(ref ProxyRpc rpc) { TransactionFlowProperty.Set(Transaction.Current, rpc.Request); }
static void SendTransaction(ref ProxyRpc rpc) { System.ServiceModel.Channels.TransactionFlowProperty.Set(Transaction.Current, rpc.Request); }
internal void BeforeSendRequest(ref ProxyRpc rpc) { int offset = this.MessageInspectorCorrelationOffset; try { for (int i = 0; i < _messageInspectors.Length; i++) { ServiceChannel clientChannel = ServiceChannelFactory.GetServiceChannel(rpc.Channel.Proxy); rpc.Correlation[offset + i] = _messageInspectors[i].BeforeSendRequest(ref rpc.Request, clientChannel); if (TD.ClientMessageInspectorBeforeSendInvokedIsEnabled()) { TD.ClientMessageInspectorBeforeSendInvoked(rpc.EventTraceActivity, _messageInspectors[i].GetType().FullName); } } } catch (Exception e) { if (Fx.IsFatal(e)) { throw; } if (ErrorBehavior.ShouldRethrowClientSideExceptionAsIs(e)) { throw; } throw DiagnosticUtility.ExceptionUtility.ThrowHelperCallback(e); } }
static void SendTransaction(ref ProxyRpc rpc) { System.ServiceModel.Channels.TransactionFlowProperty.Set(Transaction.Current, rpc.Request); }