Reputation: 4751
Do Svcutil generated proxies give better performance over ChannelFactory used at runtime? Does ChannelFactory cache proxy by default?
I am using .NET 4 with a service which has more than 100 operations and more than 500 data contracts participating in it.
When I use ChannelFactory<T>
, it takes a really long time to return me the proxy. Can one suggest which is the best way to create a proxy?
My code looks like this:
EndpointAddress endPoint = new EndpointAddress(url);
// My own API which gives the custom binding I create programatically
CustomBinding binding = BindingFactory.GetCustomBinding("WSECustomBinding");
ChannelFactory<T> factory = new ChannelFactory<T>(binding, endPoint);
Upvotes: 4
Views: 3445
Reputation: 24580
When you generate code with Svcutil, you get a class extending ClientBase
, which is a wrapper for ChannelFactory
.
Svcutil proxies allow you to invoke the service as methods on objects instead of interacting directly with ChannelFactories/Channels and apart that, do offer some extra functionality, like caching channel factories, but under the hood it's the same engine.
It's not clear from your code what you are doing, but are you creating the ChannelFactory on each operation call? Creation of ChannelFactory is expensive and you usually cache that instance to then use it to open, make use of, then close Channels for operation calls.
See the following pages for more detailed explanations:
Upvotes: 2