wcf - How to change basicHttpBinding sendTimeout at runtime? -


i have small, basic working example of using wcf 2 applications talk each other. client app, listens server, has xml in app.config file configures settings. 1 setting hard-coded @ compile time sendtimeout settings buried under basichttpbinding setting. example:

<configuration>     <system.servicemodel>         <bindings>             <basichttpbinding>                 <binding name="basichttpbinding_iscriptrunhost" closetimeout="00:05:00"                     opentimeout="00:05:00" receivetimeout="00:05:00" sendtimeout="00:00:15" 

i able set sendtimeout property @ runtime (using c#). being new wcf don't know start?

you can whatever in config file, in code. can set timeouts or various configuration details dynamically creating new client proxy , assigning desired binding configurations @ run time:

serviceclient _client = new serviceclient(new basichttpbinding { sendtimeout = new timespan(2, 0, 0) },new endpointaddress("http://localhost:8089/myservice.svc")); 

or:

basichttpbinding mybinding = new basichttpbinding();                  mybinding.opentimeout = new timespan(2, 0, 0);                  mybinding.closetimeout = new timespan(2, 0, 0);                  mybinding.sendtimeout = new timespan(2, 0, 0);  serviceclient _client = new serviceclient();               _client.endpoint.binding = mybinding; 

but can infer glancing @ code, if want change timeout values, service endpoint, or pretty of binding configurations @ run time, you'd have tear down previous client proxy , dispose of , use new 1 created, has undesired effect clients momentarily disconnected service, bear in mind. define 2 or 3 (or many wish) binding configurations in config file, , create new client , configure use binding, identical doing in code. way you'd have instantiate new client proxy able use different binding configuration.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -