internal void AfterReceiveReply(ref ProxyRpc rpc) { int offset = MessageInspectorCorrelationOffset; try { for (int i = 0; i < messageInspectors.Length; i++) { messageInspectors[i].AfterReceiveReply(ref rpc.Reply, rpc.Correlation[offset + i]); //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 BeforeSendRequest(ref ProxyRpc rpc) { int offset = MessageInspectorCorrelationOffset; try { for (int i = 0; i < messageInspectors.Length; i++) { rpc.Correlation[offset + i] = messageInspectors[i].BeforeSendRequest(ref rpc.Request, (IClientChannel)rpc.Channel.Proxy); //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 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, this._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, Name, rpc.Request.Headers.Action ?? "{NULL}", Action))); } } }
internal ProxyOperationRuntime GetOperation(MethodBase methodBase, object[] args, out bool canCacheResult) { if (operationSelector == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException (SR.Format(SR.SFxNeedProxyBehaviorOperationSelector2, methodBase.Name, methodBase.DeclaringType.Name))); } try { if (operationSelector.AreParametersRequiredForSelection) { canCacheResult = false; } else { args = null; canCacheResult = true; } string operationName = operationSelector.SelectOperation(methodBase, args); ProxyOperationRuntime operation; if ((operationName != null) && operations.TryGetValue(operationName, out operation)) { return(operation); } else { // did not find the right operation, will not know how // to invoke the method. return(null); } } catch (Exception e) { if (Fx.IsFatal(e)) { throw; } if (ErrorBehavior.ShouldRethrowClientSideExceptionAsIs(e)) { throw; } throw DiagnosticUtility.ExceptionUtility.ThrowHelperCallback(e); } }
// this should not be inlined, since we want to JIT the reference to System.Transactions // only if transactions are being flowed. //[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] //static void SendTransaction(ref ProxyRpc rpc) //{ // System.ServiceModel.Channels.TransactionFlowProperty.Set(Transaction.Current, rpc.Request); //} internal void InitializeChannel(IClientChannel channel) { try { for (int i = 0; i < channelInitializers.Length; ++i) { channelInitializers[i].Initialize(channel); } } catch (Exception e) { if (Fx.IsFatal(e)) { throw; } if (ErrorBehavior.ShouldRethrowClientSideExceptionAsIs(e)) { throw; } throw DiagnosticUtility.ExceptionUtility.ThrowHelperCallback(e); } }
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, 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.Format(SR.SFxHeaderNotUnderstood, headersNotUnderstood[0].Name, headersNotUnderstood[0].Namespace))); } } } }