Thursday, June 28, 2007 7:27 PM
I noticed this today and wanted to know if anyone could pinpoint the reason it is happening:
I implemented an OperationBehavior in the form of an attribute as follows:
publicclass ExtensionAttribute: Attribute, IOperationBehavior
I decorate a service method with the attribute and run the service and a client that calls the service.
I found that the ApplyDispatchBehavior method on the OperationBehavior class gets invoked but the ApplyClientBehavior doesn't when the client code doesn't explicitly create the channel using the ChannelFactory's CreateChannel method.
If you simply add a service reference and new up the proxy directly relying on the information in your config file and the proxy to do all the setup work for you, and the call a method on the proxy (which is probably what most client side developers will do) the ApplyClientBehavior never gets called.
Can anyone offer some insight as to why this is true?
Thursday, June 28, 2007 10:18 PMModerator
It is actually happening here because the client used does not have the operationBehavior. When you use client generated with add service reference, the behaviors are not added. Client is generated from the service wsdl. Behaviors are not exported to wsdl. These would not be in wsdl as these are just runtime entities. You could add this behaviorattribute explicitly in generated code.
Tuesday, January 06, 2009 5:34 PMDo you have an example of how to apply this attribute on the client side? What I am trying to do is override the XmlObjectSerializer to preserve object references (i.e. New DataContractSerializer(type, name, ns, knownTypes, &H7FFF, False, True, Nothing). Any help would be appreciated.