tags:

views:

164

answers:

1

i'm trying to reply a wcf request in 'AfterReceiveRequest' method of message inspector (implements IDispatchMessageInspector)

  XmlReader xmlReader = XmlReader.Create(
    new StringReader(string.Format(@"<{0}Response xmlns='{1}' />",methodName,namespace)));

  Message replyMsg = Message.CreateMessage(request.Version, request.Headers.Action, xmlReader);
  OperationContext.Current.RequestContext.Reply(replyMsg);

client gets the response immediately by this way.

Rest of the task is to break the execution on server and end up without a fault.

request.Close() breaks the execution, but if you take a look at message in 'BeforeSendReply' ,, it creates a fault.

well its not appropriate for us, and looking for a convenient termination. is there anyway to do it??

thanks.

Ali TAKAVCI

A: 

This is likely expected behavior. I don't think you'll be able to get around this.

Using a message inspector for anything but observation or adaptation before passing a message off to a method is probably a bad idea. It seems like what you are trying to do is more appropriate for the implementation of your operation. You should see a message inspector as the chance to see a message or tweak it before it's handed off to the dispatcher.

Anderson Imes
actually it is the place that authentication, authorization and logging tasks occur, and anything between these tasks and actual action execution should be placed in inspectors 'AfterRequestReceive' method. It works like a single-point-entry implementation.so if you have an advice about where all these tasks should be done, it will be appreciated.