June 02, 2004

DispatchFailed

When trying to understand why your application doesn't seem to be processing the messages you are sending, it can be helpful to detect and monitor message dispatch failures from the WSE2 messaging layer. This is the purpose of the static SoapTransport.DispatchFailed event. You can hook this event anywhere in your application and have your callback invoked when a transport fails to dispatch an incoming message to a registered input channel. Here's the code to do this:

[MTAThread]
static void Main(string[] args)
{
SoapTransport.DispatchFailed +=
new SoapTransport.DispatchFailedEventHandler(OnDispatchFailed);

...

}

static void OnDispatchFailed(object sender, SoapTransport.DispatchFailedEventArgs e)
{
Console.WriteLine("Dispatch Failed!");
}

The sender is the transport that failed to dispatch and the DispatchFailedEventArgs has a property called Message that is the SoapEnvelope that could not be dispatched.

Note that this event is not fired by the built-in HTTP transport that is hosted under ASP.NET. It is fired by soap.tcp and soap.inproc. Custom transports that use the SoapTransport.DispatchMessage method to dispatch incoming messages will also fire this event.

Posted by herveyw at June 2, 2004 11:35 PM
Comments

Thanks Hervey,

it's a nice feature built-in the DispatchMessage to fire (Invoke) this event in the base class - SoapTransport.

In the case of the Custom Transport + Custom DispatchMessage this event can't be fired. I am using the following workaround:

if(DispatchMessage2(message) == false)
DispatchMessage(message);

where the DispatchMessage2 method is my custom message dispatcher.

Notice that it will be nice to have access to fire this event from the derived class.

Thanks.

Roman

Posted by: Roman Kiss at June 7, 2004 10:42 AM