Reputation: 10888
I have added reference to WCF Service in my client asp.net website.
Right now, I am just instantiating WCF Service at every service method call as:
TemplateServiceClient objTemplateService = new TemplateServiceClient();
objTemplateService.MethodCall();
I am not sure about the performance down due to above.
If it is going to be a performance hit, Can you suggest me a better approach to call my service methods.
Thank you!
Upvotes: 0
Views: 1846
Reputation: 754468
As long as the performance is acceptable, it's not a problem. Don't over-optimize prematurely without even knowing whether there indeed IS a performance problem or not...
Measure your performance, and see, if it is.
The per-call scenario is indeed the preferred and recommended scenario for WCF - it just works best that way, no hairy mess with stateful services, sessions or singleton - it just works and scales quite well to even fairly heavy loads.
Upvotes: 0
Reputation: 4815
The only way to know about performance is to test it, so if you've any concerns, you should do that.
It's hard to know without knowing what you're doing and how it will be used.
A web service client is just another object so you can do all the usual things:
Personally, I tend to end up with the second for most things I do but that fits my usage profile.
Upvotes: 3