Can I add WCF custom settings from my user binding?

I am writing a custom WCF binding, and I want to run some code only if there is a problem processing the message. I was thinking of adding a custom IOperationInvoker and using try / catch to process the message. I cannot find a way to add custom behavior from my binding. I would like to avoid having to declare BOTH binding and behavior for any services that want to use this binding.

The model I ran away with is the Net.Msmq binding, where you can declare retry processing through the binding. This, in fact, is what I am trying to reproduce, but through my own binding.

Any WCF gurus out there?

+4
source share
1 answer

I think that this is impossible. Binding cannot add behavior. You can check the default WCF bindings - for example, WebHttpBinding always used in combination with WebHttpBehavior or WebScriptEnablingBehavior , but WebHttpBinding cannot add them, you must add them manually. To solve this inconvenience, WCF offers the WebServiceHost class, which can be used instead of the usual ServiceHost . WebServiceHost does all the necessary configuration for the REST service — it adds WebHttpBehavior and enpoint using WebHttpBinding. You can use the same approach.

But I think this is not a very good approach. Reprocessing is already being processed by ReliableSession, and it is implemented as a pipe, so you should probably try the same way. In this case, you do not have to deal with the problem of behavior.

+1
source

Source: https://habr.com/ru/post/1336855/


All Articles