Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add callback message inpector #4699

Merged
merged 6 commits into from
Sep 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions src/System.Private.ServiceModel/src/Internals/WcfEventSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,46 @@ public void FaultProviderInvoked(string TypeName, string ExceptionTypeName)
FaultProviderInvoked(TypeName, ExceptionTypeName, "", "");
}

public bool MessageInspectorAfterReceiveInvokedIsEnabled()
{
return base.IsEnabled(EventLevel.Informational, Keywords.Troubleshooting | Keywords.ServiceModel, EventChannel.Analytic);
}

[Event(EventIds.MessageInspectorAfterReceiveInvoked, Level = EventLevel.Informational, Channel = EventChannel.Analytic, Opcode = Opcodes.DispatchMessageDispathMessageInspectorAfterReceiveInvoked, Task = Tasks.DispatchMessage,
Keywords = Keywords.Troubleshooting | Keywords.ServiceModel,
Message = "The Dispatcher invoked 'AfterReceiveReply' on a MessageInspector of type '{0}'.")]
public void MessageInspectorAfterReceiveInvoked(string TypeName, string HostReference, string AppDomain)
{
WriteEvent(EventIds.MessageInspectorAfterReceiveInvoked, TypeName, HostReference, AppDomain);
}

[NonEvent]
public void MessageInspectorAfterReceiveInvoked(EventTraceActivity eventTraceActivity, string TypeName)
{
SetActivityId(eventTraceActivity);
MessageInspectorAfterReceiveInvoked(TypeName, "", "");
}

public bool MessageInspectorBeforeSendInvokedIsEnabled()
{
return base.IsEnabled(EventLevel.Informational, Keywords.Troubleshooting | Keywords.ServiceModel, EventChannel.Analytic);
}

[Event(EventIds.MessageInspectorBeforeSendInvoked, Level = EventLevel.Informational, Channel = EventChannel.Analytic, Opcode = Opcodes.DispatchMessageDispathMessageInspectorBeforeSendInvoked, Task = Tasks.DispatchMessage,
Keywords = Keywords.Troubleshooting | Keywords.ServiceModel,
Message = "The Dispatcher invoked 'BeforeSendRequest' on a MessageInspector of type '{0}'.")]
public void MessageInspectorBeforeSendInvoked(string TypeName, string HostReference, string AppDomain)
{
WriteEvent(EventIds.MessageInspectorBeforeSendInvoked, TypeName, HostReference, AppDomain);
}

[NonEvent]
public void MessageInspectorBeforeSendInvoked(EventTraceActivity eventTraceActivity, string TypeName)
{
SetActivityId(eventTraceActivity);
MessageInspectorBeforeSendInvoked(TypeName, "", "");
}

public bool ParameterInspectorAfterCallInvokedIsEnabled()
{
return base.IsEnabled(EventLevel.Informational, Keywords.Troubleshooting | Keywords.ServiceModel, EventChannel.Analytic);
Expand Down
5 changes: 4 additions & 1 deletion src/System.Private.ServiceModel/src/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -3000,4 +3000,7 @@
<data name="SFxActionMismatch" xml:space="preserve">
<value>Cannot create a typed message due to action mismatch, expecting {0} encountered {1}</value>
</data>
</root>
<data name="SFxNullReplyFromExtension2" xml:space="preserve">
<value>Extension {0} prevented call to operation '{1}' from replying by setting the reply to null.</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -3227,6 +3227,11 @@
<target state="translated">Hodnota NONE elementu WS-Addressing není platná pro verzi elementu WS-Addressing ze srpna 2004.</target>
<note />
</trans-unit>
<trans-unit id="SFxNullReplyFromExtension2">
<source>Extension {0} prevented call to operation '{1}' from replying by setting the reply to null.</source>
<target state="new">Extension {0} prevented call to operation '{1}' from replying by setting the reply to null.</target>
<note />
</trans-unit>
<trans-unit id="SFxNullReplyFromFormatter2">
<source>Formatter {0} returned a null reply message for call to operation '{1}'.</source>
<target state="translated">Formátovací modul {0} vrátil zprávu odpovědi s hodnotou NULL pro volání do operace {1}.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3227,6 +3227,11 @@
<target state="translated">Der Wert "none" der WS-Adressierung ist für die August 2004-Version der WS-Adressierung nicht gültig.</target>
<note />
</trans-unit>
<trans-unit id="SFxNullReplyFromExtension2">
<source>Extension {0} prevented call to operation '{1}' from replying by setting the reply to null.</source>
<target state="new">Extension {0} prevented call to operation '{1}' from replying by setting the reply to null.</target>
<note />
</trans-unit>
<trans-unit id="SFxNullReplyFromFormatter2">
<source>Formatter {0} returned a null reply message for call to operation '{1}'.</source>
<target state="translated">Der Formatierer {0} hat eine leere Antwortnachricht für einen Aufruf des Vorgangs "{1}" zurückgegeben.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3227,6 +3227,11 @@
<target state="translated">El valor "none" de WS-Addressing no es válido para la versión de agosto de 2004 de WS-Addressing.</target>
<note />
</trans-unit>
<trans-unit id="SFxNullReplyFromExtension2">
<source>Extension {0} prevented call to operation '{1}' from replying by setting the reply to null.</source>
<target state="new">Extension {0} prevented call to operation '{1}' from replying by setting the reply to null.</target>
<note />
</trans-unit>
<trans-unit id="SFxNullReplyFromFormatter2">
<source>Formatter {0} returned a null reply message for call to operation '{1}'.</source>
<target state="translated">El formateador {0} devolvió un mensaje de respuesta nulo para la llamada a la operación "{1}".</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3227,6 +3227,11 @@
<target state="translated">La valeur 'none' de WS-Addressing n'est pas valide pour la version d'août 2004 de WS-Addressing.</target>
<note />
</trans-unit>
<trans-unit id="SFxNullReplyFromExtension2">
<source>Extension {0} prevented call to operation '{1}' from replying by setting the reply to null.</source>
<target state="new">Extension {0} prevented call to operation '{1}' from replying by setting the reply to null.</target>
<note />
</trans-unit>
<trans-unit id="SFxNullReplyFromFormatter2">
<source>Formatter {0} returned a null reply message for call to operation '{1}'.</source>
<target state="translated">Le formateur {0} a retourné un message de réponse avec une valeur null pour l'appel à l'opération '{1}'.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3227,6 +3227,11 @@
<target state="translated">Valore WS-Addressing "none" non valido per la versione di agosto 2004 di WS-Addressing.</target>
<note />
</trans-unit>
<trans-unit id="SFxNullReplyFromExtension2">
<source>Extension {0} prevented call to operation '{1}' from replying by setting the reply to null.</source>
<target state="new">Extension {0} prevented call to operation '{1}' from replying by setting the reply to null.</target>
<note />
</trans-unit>
<trans-unit id="SFxNullReplyFromFormatter2">
<source>Formatter {0} returned a null reply message for call to operation '{1}'.</source>
<target state="translated">Il formattatore {0} ha restituito un messaggio di risposta Null per la chiamata all'operazione '{1}'.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3227,6 +3227,11 @@
<target state="translated">WS-Addressing の値を "なし" にすることは、2004 年 8 月版の WS-Addressing では無効です。</target>
<note />
</trans-unit>
<trans-unit id="SFxNullReplyFromExtension2">
<source>Extension {0} prevented call to operation '{1}' from replying by setting the reply to null.</source>
<target state="new">Extension {0} prevented call to operation '{1}' from replying by setting the reply to null.</target>
<note />
</trans-unit>
<trans-unit id="SFxNullReplyFromFormatter2">
<source>Formatter {0} returned a null reply message for call to operation '{1}'.</source>
<target state="translated">フォーマッタ {0} が、操作 '{1}' への呼び出しに対して null の応答メッセージを返しました。</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3227,6 +3227,11 @@
<target state="translated">WS-Addressing "none" 값이 2004년 8월 버전의 WS-Addressing에 올바르지 않습니다.</target>
<note />
</trans-unit>
<trans-unit id="SFxNullReplyFromExtension2">
<source>Extension {0} prevented call to operation '{1}' from replying by setting the reply to null.</source>
<target state="new">Extension {0} prevented call to operation '{1}' from replying by setting the reply to null.</target>
<note />
</trans-unit>
<trans-unit id="SFxNullReplyFromFormatter2">
<source>Formatter {0} returned a null reply message for call to operation '{1}'.</source>
<target state="translated">{0} 포맷터가 '{1}' 작업의 호출에 대해 null 회신 메시지를 반환했습니다.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3227,6 +3227,11 @@
<target state="translated">Wartość WS-Addressing „none” jest nieprawidłowa dla wersji WS-Addressing z sierpnia 2004.</target>
<note />
</trans-unit>
<trans-unit id="SFxNullReplyFromExtension2">
<source>Extension {0} prevented call to operation '{1}' from replying by setting the reply to null.</source>
<target state="new">Extension {0} prevented call to operation '{1}' from replying by setting the reply to null.</target>
<note />
</trans-unit>
<trans-unit id="SFxNullReplyFromFormatter2">
<source>Formatter {0} returned a null reply message for call to operation '{1}'.</source>
<target state="translated">Program formatujący {0} zwrócił komunikat odpowiedzi o wartości null dla wywołania operacji „{1}”.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3227,6 +3227,11 @@
<target state="translated">O valor "none" do WS-Addressing não é válido para a versão de agosto de 2004 do WS-Addressing.</target>
<note />
</trans-unit>
<trans-unit id="SFxNullReplyFromExtension2">
<source>Extension {0} prevented call to operation '{1}' from replying by setting the reply to null.</source>
<target state="new">Extension {0} prevented call to operation '{1}' from replying by setting the reply to null.</target>
<note />
</trans-unit>
<trans-unit id="SFxNullReplyFromFormatter2">
<source>Formatter {0} returned a null reply message for call to operation '{1}'.</source>
<target state="translated">O formatador {0} retornou uma mensagem de resposta nula da chamada para a operação '{1}'.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3227,6 +3227,11 @@
<target state="translated">Значение WS-Addressing "none" недопустимо для версии WS-Addressing августа 2004 г.</target>
<note />
</trans-unit>
<trans-unit id="SFxNullReplyFromExtension2">
<source>Extension {0} prevented call to operation '{1}' from replying by setting the reply to null.</source>
<target state="new">Extension {0} prevented call to operation '{1}' from replying by setting the reply to null.</target>
<note />
</trans-unit>
<trans-unit id="SFxNullReplyFromFormatter2">
<source>Formatter {0} returned a null reply message for call to operation '{1}'.</source>
<target state="translated">Модуль форматирования {0} вернул нулевое ответное сообщение для вызова операции "{1}".</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3227,6 +3227,11 @@
<target state="translated">WS-Addressing "none" değeri, WS-Addressing Ağustos 2004 sürümü için geçerli değil.</target>
<note />
</trans-unit>
<trans-unit id="SFxNullReplyFromExtension2">
<source>Extension {0} prevented call to operation '{1}' from replying by setting the reply to null.</source>
<target state="new">Extension {0} prevented call to operation '{1}' from replying by setting the reply to null.</target>
<note />
</trans-unit>
<trans-unit id="SFxNullReplyFromFormatter2">
<source>Formatter {0} returned a null reply message for call to operation '{1}'.</source>
<target state="translated">{0} biçimlendiricisi '{1}' işlemi çağrısı için bir null yanıt iletisi döndürdü.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3227,6 +3227,11 @@
<target state="translated">WS-Addressing "none" 值对 2004 年 8 月版本的 WS-Addressing 无效。</target>
<note />
</trans-unit>
<trans-unit id="SFxNullReplyFromExtension2">
<source>Extension {0} prevented call to operation '{1}' from replying by setting the reply to null.</source>
<target state="new">Extension {0} prevented call to operation '{1}' from replying by setting the reply to null.</target>
<note />
</trans-unit>
<trans-unit id="SFxNullReplyFromFormatter2">
<source>Formatter {0} returned a null reply message for call to operation '{1}'.</source>
<target state="translated">格式化程序 {0} 对操作“{1}”的调用返回了空回复消息。</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3227,6 +3227,11 @@
<target state="translated">WS-Addressing "none" 值對於 WS-Addressing August 2004 版本無效。</target>
<note />
</trans-unit>
<trans-unit id="SFxNullReplyFromExtension2">
<source>Extension {0} prevented call to operation '{1}' from replying by setting the reply to null.</source>
<target state="new">Extension {0} prevented call to operation '{1}' from replying by setting the reply to null.</target>
<note />
</trans-unit>
<trans-unit id="SFxNullReplyFromFormatter2">
<source>Formatter {0} returned a null reply message for call to operation '{1}'.</source>
<target state="translated">格式器 {0} 對作業 '{1}' 的呼叫,傳回了 null 的回覆訊息。</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public sealed class DispatchRuntime
private ChannelDispatcher _channelDispatcher;
private IInstanceProvider _instanceProvider;
private IInstanceContextProvider _instanceContextProvider;
private SynchronizedCollection<IDispatchMessageInspector> _messageInspectors;
private OperationCollection _operations;
private ImmutableDispatchRuntime _runtime;
private SynchronizationContext _synchronizationContext;
Expand All @@ -42,6 +43,7 @@ private DispatchRuntime(SharedRuntimeState shared)
_shared = shared;

_operations = new OperationCollection(this);
_messageInspectors = NewBehaviorCollection<IDispatchMessageInspector>();
_synchronizationContext = ThreadBehavior.GetCurrentSynchronizationContext();
_automaticInputSessionShutdown = true;

Expand Down Expand Up @@ -157,6 +159,11 @@ public IInstanceProvider InstanceProvider
}
}

public SynchronizedCollection<IDispatchMessageInspector> MessageInspectors
{
get { return _messageInspectors; }
}

public SynchronizedKeyedCollection<string, DispatchOperation> Operations
{
get { return _operations; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,11 @@ internal bool HandleError(Exception error, ref ErrorHandlerFaultInfo faultInfo)
return HandleErrorCommon(error, ref faultInfo);
}

internal static bool ShouldRethrowExceptionAsIs(Exception e)
{
return true;
}

internal static bool ShouldRethrowClientSideExceptionAsIs(Exception e)
{
return true;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.


using System.ServiceModel.Channels;

namespace System.ServiceModel.Dispatcher
{
public interface IDispatchMessageInspector
{
object AfterReceiveRequest(ref Message request, IClientChannel channel, InstanceContext instanceContext);
void BeforeSendReply(ref Message reply, object correlationState);
}
}
Loading