This is strange, but (checks the code). I only ever apply changes to the endpoint provided to me by WCF:
void IEndpointBehavior.ApplyClientBehavior(ServiceEndpoint endpoint, System.ServiceModel.Dispatcher.ClientRuntime clientRuntime) { ReplaceDataContractSerializerOperationBehavior(endpoint); } void IEndpointBehavior.ApplyDispatchBehavior(ServiceEndpoint endpoint, System.ServiceModel.Dispatcher.EndpointDispatcher endpointDispatcher) { ReplaceDataContractSerializerOperationBehavior(endpoint); } private static void ReplaceDataContractSerializerOperationBehavior(ServiceEndpoint serviceEndpoint) { foreach (OperationDescription operationDescription in serviceEndpoint.Contract.Operations) { ReplaceDataContractSerializerOperationBehavior(operationDescription); } } private static void ReplaceDataContractSerializerOperationBehavior(OperationDescription description) { DataContractSerializerOperationBehavior dcsOperationBehavior = description.Behaviors.Find<DataContractSerializerOperationBehavior>(); if (dcsOperationBehavior != null) { description.Behaviors.Remove(dcsOperationBehavior); description.Behaviors.Add(new ProtoOperationBehavior(description)); } }
i.e. "given the endpoint (according to WCF), iterate over each operation (method) at that endpoint and change the serializer from DCS to PB"
This raises the intriguing possibility that the definitions of contracts (and therefore the definitions of operations) themselves are shared between all endpoints, but I'm honestly not sure about that. If so, I do not see that it is possible to have different processors per endpoint. However, I am not a WCF guru. This is ... puzzling.
Marc gravell
source share