By default a Wcf service will validate all incoming mustUnderstand headers a client sends. If it does not understand them it will throw the famous 'Did not understand "MustUnderstand" header' exception. Typically you would instruct Wcf not to validate these headers like this:
But this kind of "hard codes" this behavior to the service. Wouldn't it be nice to decide at the configuration level if we want such a behavior or not?
All we need to do is define this class:
Then in the config register it:
And we can now configure our endpoint(s) with this behavior:
What's next? get this blog rss updates or register for mail updates!
4 comments:
Hi Yaron,
Kindly need help you advise about my problem.
I've tried to add MustunderstandBehaviour to my service
MustUnderstandBehavior mustUnderstand = new MustUnderstandBehavior(false);
mustUnderstand.ValidateMustUnderstand = false;
client.ChannelFactory.Endpoint.Behaviors.Add(mustUnderstand);
but it seems the mustundertand = "1", i want to change from "1" to "0"
Thanks.
to set mustunderstand to 0 you should implement a custom encoder. I believe you want to set it for outgoing requests while this post deals with incoming responses.
Hi Yaron,
Yes, I've tried to make a custom encoder to make it became 0, but after im save the modified xml. I got the canonical issue. It seems the format should be followed canonical format.
Need your advise!!
not sure I understand, what is the canonical issue?
Post a Comment