What am I missing about WCF?

前端 未结 8 2402
萌比男神i
萌比男神i 2020-12-12 17:05

I\'ve been developing in MS technologies for longer than I care to remember at this stage. When .NET arrived on the scene I thought they hit the nail on the head and with ea

8条回答
  •  北荒
    北荒 (楼主)
    2020-12-12 17:32

    To address the problem of maintenance nightmare of application config, some standard like UDDI or WS-Discovery exist, WS-Discovery will be supported by WCF in .NET 4.0.

    Keeping the configuration of the interfaces in code rather than moving to explicitly defined interfaces in XML, which can be published and consumed by almost anything. I know we can export the XML from the assembley, but it's full of rubbish and certain code generators choke on it.

    Can you be more explicit ? I think you are talking about service behavior configured in code. You can easily code behavior extensions to configure what your are talking about in config file instead of code BUT I think that if microsoft didn't do that there is a good reason. For example a service with this behavior :

    [ServiceBehavior(InstanceContextMode=InstanceContextMode.PerCall, ConcurrencyMode=ConcurrencyMode.Single)]
    

    The implementation knows that the instance is not shared between multiple thread so it's developed differently than :

    [ServiceBehavior(InstanceContextMode=InstanceContextMode.Single, ConcurrencyMode=ConcurrencyMode.Multiple)]
    

    In this case the service implementation should take care about concurency problems. The implementation is coupled with the attribute ServiceBehavior, so moving this behavior in a XML file is not a good idea.

    What if you can change a InstanceContextMode.PerCall service to a InstanceContextMode.Single service inside the config file ? You break the application !

提交回复
热议问题