i have no enthusiasm to write blogs those days,but i still believe that writing can enrich and help my memory,so make a note about what i am learning.today’s topic is WCF Operation Selector.following is a brief description.
after the wcf service is hosted.it will create a ChannelDispatcher(ps:how many ChannelDispatchers will be created,which depends on how many listenUrls the service has.there is only one listenUrl today,so there is only one ChannelDispatcher).as we know every ChannelDispatcher has a corresponding ChannelListener(it is very important but not today’s topic,if time is enough,i will describe in another post).
now ChannelDispatcher is available,it is time that the ChannelDispatcher showed its function.ChannelDispatcher will transfer the mesage to the EndointDispacher with the help of AddressMessageFilter and ContractMessageFilter(maybe we can find somtheing from their names ).At the same time,ChannelDispatcher also creates a collection named as DispachOperation in which all operations of the current endpoint are included.
So we have an operation collection,but how the message reaches the very expected operation.there is another object,OperationSelector(we can also find somthing from it name), which can return the very expected operation by analyzing the mesage(how? i also need help? can you?).
Now,you may find that it is impossible for a WCF service to have two operations which have the same name.if that,how the OperationSelector works?
There will be another question,if we cannot have a service with two operations which have the same name,it means that we cannot overload the method in a service.frankly speaking.it is true.you know,wcf is designed for SOA,but WCF Service is also programmed by OOP language(like C#).how do we fix this conflict? is there any solution for this conflict? the anwser is true.we can use the attribute to update the operation’s default name. a simple code.
[ServiceContract]
public interface IOverLoadDemo
{
[OperationContract(Name = "AddDouble")]
double Add(double p1, double p2);
[OperationContract(Name = "AddInt")]
int Add(int p1, int p2);
}
PS:windows live writer 2011 is better than previous version