c# - wsHttpBinding MessageSecurityException after runtime Web.config write update -
i using default wshttpbinding
on iis hosted wcf service.
<service behaviorconfiguration="wcfservice.mybehavior" name="wcfservice.myservice"> <endpoint address="" binding="wshttpbinding" contract="common.imyservice" name="wshttpbinding_mywcfservice"> </endpoint> <endpoint address="mex" binding="mexhttpbinding" contract="imetadataexchange"/> </service>
i know bad practice wcf service must update web.config file.
system.configuration.configuration config = system.web.configuration.webconfigurationmanager.openwebconfiguration("~"); system.configuration.connectionstringssection section = config.getsection("connectionstrings") system.configuration.connectionstringssection; section.connectionstrings["mainconnection"].connectionstring = newvalue; system.configuration.configurationmanager.appsettings["dataproviderusername"] = username; system.configuration.configurationmanager.appsettings["dataproviderpassword"] = password; config.save(system.configuration.configurationsavemode.modified); system.configuration.configurationmanager.refreshsection("connectionstrings");
i able , winforms client desired response exception thrown when disposing client.
using (myclient client = new myclient(new system.servicemodel.wshttpbinding(), endpoint)) { var result = client.getresult(myparams); var success=result.succsess;//result correct }//throws on disposing
here servicemodel.fault exception inside messagesecurityexception
the message not processed. because action 'http://schemas.xmlsoap.org/ws/2005/02/trust/rst/sct/cancel' incorrect or because message contains invalid or expired security context token or because there mismatch between bindings. security context token invalid if service aborted channel due inactivity. prevent service aborting idle sessions prematurely increase receive timeout on service endpoint's binding.
if don´t update web.config file no exception thrown. there way can still use wshttpbinding , update web.config file @ runtime?
it generic error. misleading actual issue tns file. fixed putting correct tns entry of db.
Comments
Post a Comment