Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting WCF InstanceContextMode (Per Call, Single) in web.confg

Haven't come across this one with quite a bit of Googling.

I know I can set the instance by decorating the class name thus:

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

but can I specify this in the web.config file?

I know I can specify throttling (max concurrent users etc) in the web.config / app.config and that the numbers here have a context depending on the instance mode - but how to specify the mode (in most likely the behaviours section of the app.config / web.config)?

Originally we were going for Windows services. Now we are using WAS. Does WAS make any difference - eg. each 'per call' request will still get's it own 'server' as a pipeline operation?

Thanks

like image 936
wcfhopeful Avatar asked Apr 26 '11 06:04

wcfhopeful


People also ask

What is InstanceContextMode in WCF?

InstanceContextMode property to specify the lifetime of the InstanceContext object. Windows Communication Foundation (WCF) can create a new InstanceContext object for every call, every session, or specify that the InstanceContext object is bound to a single service object. For a working example, see Instancing.

Which problem can occur when WCF service with concurrency mode multiple is hosted using Windows Forms application?

Notice that when the concurrency mode is Multiple , the results are returned in a different order than how they were called, because the service processes multiple messages concurrently.

In which instance mode complete session of a user is maintained?

WCF can maintain a session between a client and a particular service instance. When the client creates a new proxy to a service configured as a sessionful service, the client gets a new dedicated service instance that is independent of all other instances of the same service.

Which of the following are the concurrency modes in WCF service?

There are three basic types of concurrency supported by WCF 4.0: Single Concurrency Mode. Multiple Concurrency Mode. Reentrant Concurrency Mode.


1 Answers

You can not configure InstanceContextMode and ConcurrencyMode in config files, build in limitation in the WCF, i am sure MS has their reasons.

About hosting in WAS, if you have a web server with IIS 7/7.5 it is recommended to host your service with WAS because you can manage your services with the IIS management and get a lot of built in capabilities from it.

like image 88
Gilad Levy Avatar answered Sep 24 '22 16:09

Gilad Levy