[Mono-bugs] [Bug 619534] New: Message filter using BeforeSendReply from IDispatchMessageInspector does not work as in Microsoft NET Framework
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Fri Jul 2 08:46:12 EDT 2010
http://bugzilla.novell.com/show_bug.cgi?id=619534
http://bugzilla.novell.com/show_bug.cgi?id=619534#c0
Summary: Message filter using BeforeSendReply from
IDispatchMessageInspector does not work as in
Microsoft NET Framework
Classification: Mono
Product: Mono: Class Libraries
Version: 2.6.x
Platform: Macintosh
OS/Version: Mac OS X 10.6
Status: NEW
Severity: Major
Priority: P5 - None
Component: WCF
AssignedTo: atsushi at ximian.com
ReportedBy: clovis.ribeiro at myabcm.com
QAContact: mono-bugs at lists.ximian.com
Found By: ---
Blocker: ---
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-us)
AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16
If you create a message filter using IDispatchMessageInspector interface
implementing BeforeSendReply and decide to completely replace the message
inside, Mono ignores the replaced message.
Example:
If you write a message handler like the one below, the new message added to
reply is ignored.
public void BeforeSendReply(ref System.ServiceModel.Channels.Message reply,
object correlationState)'
{
reply = Message.CreateMessage(reply.Version, reply.Headers.Action,
String.Empty);
}
After looking at Mono sources, file MessageProcessingContext.cs, I realized
there is an error in BeforeSendReply() (line 125) that is not updating the
ReplyMessage after calling the message inspectors. I fixed the code by doing
the following:
public void BeforeSendReply ()
{
Message toBeChanged = request_context.ReplyMessage;
for (int i = 0; i < dispatch_runtime.MessageInspectors.Count; ++i)
dispatch_runtime.MessageInspectors [i].BeforeSendReply (ref
toBeChanged, msg_inspectors_states [i]);
request_context.ReplyMessage = toBeChanged;
}
Note that I only added an extra line to write the toBeChanged back to
request_context.ReplyMessage.
This is exactly what is already being done in AfterReceiveRequest().
My final point here is: although we have not tested yet because we are using
only one message filter, I believe you should add the
request_context.ReplyMessage = toBeChanged inside the for() loop. If you don't
do that, only the last inspector will work correctly. I say that for
BeforeSendReply() AND AfterReceiveRequest().
Hope this helps and feel free to contact me as I have been digging inside this
code for awhile.
Reproducible: Always
Steps to Reproduce:
Create a message inspector by implementing
IDispatchMessageInspector.BeforeSendReply() and completely replace the reply
message inside BeforeSendReply()
Actual Results:
The new message is ignored.
Expected Results:
The new message should be sent back to the client.
--
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
More information about the mono-bugs
mailing list