c# - IClientMessageInspector not working in WCF -


i have class messageinspector implements iclientmessageinspector.

namespace wcfauthentication {     public class messageinspector : iclientmessageinspector     {          public void afterreceivereply(ref system.servicemodel.channels.message reply, object correlationstate)         {             //throw new notimplementedexception();             debug.writeline("iclientmessageinspector.afterreceivereply called.");             debug.writeline("message: {0}", reply.tostring());         }          public object beforesendrequest(ref system.servicemodel.channels.message request, system.servicemodel.iclientchannel channel)         {             //throw new notimplementedexception();             debug.writeline("iclientmessageinspector.beforesendrequest called.");             return null;         }     } } 

i have configured in web.config of wcf :

<?xml version="1.0"?> <configuration>    <appsettings>     <add key="aspnet:usetaskfriendlysynchronizationcontext" value="true" />   </appsettings>   <system.web>     <compilation debug="true" targetframework="4.5" />     <httpruntime targetframework="4.5"/>   </system.web>   <system.servicemodel>     <extensions>       <behaviorextensions>         <add           name="messageinspector"           type="wcfauthentication.messageinspector, messageinspector, version=0.0.0.0, culture=neutral, publickeytoken=null"/>       </behaviorextensions>     </extensions>     <behaviors>       <servicebehaviors>         <behavior>           <!-- avoid disclosing metadata information, set values below false before deployment -->           <servicemetadata httpgetenabled="true" httpsgetenabled="true"/>           <!-- receive exception details in faults debugging purposes, set value below true.  set false before deployment avoid disclosing exception information -->           <servicedebug includeexceptiondetailinfaults="false"/>         </behavior>       </servicebehaviors>       <endpointbehaviors>         <behavior name="restfulbehavior">           <webhttp/>         </behavior>         <behavior name="restfulbehavior_jwt">           <webhttp/>           <messageinspector/>         </behavior>       </endpointbehaviors>     </behaviors>     <services>       <service name ="wcfauthentication.service1">         <endpoint address="" behaviorconfiguration="restfulbehavior_jwt" binding="webhttpbinding" contract="wcfauthentication.iservice1"/>       </service>       <service name ="wcfauthentication.authentication">         <endpoint address="" behaviorconfiguration="restfulbehavior" binding="webhttpbinding" contract="wcfauthentication.iauthentication"/>       </service>     </services>       <protocolmapping>       <add binding="basichttpsbinding" scheme="https" />     </protocolmapping>     <servicehostingenvironment aspnetcompatibilityenabled="true" multiplesitebindingsenabled="true" />   </system.servicemodel>   <system.webserver>     <modules runallmanagedmodulesforallrequests="true"/>     <!--         browse web app root directory during debugging, set value below true.         set false before deployment avoid disclosing web app folder information.       -->     <directorybrowse enabled="true"/>   </system.webserver>  </configuration> 

while running wcf ( hosted in iis), not able recognize "messageinspector" class in config.

server error in '/wcfauthentication' application.

configuration error

description: error occurred during processing of configuration file required service request. please review specific error details below , modify configuration file appropriately.

parser error message: type 'wcfauthentication.messageinspector, messageinspector, version=0.0.0.0, culture=neutral, publickeytoken=null' registered extension 'messageinspector' not loaded.

source error:    line 32:         <behavior name="restfulbehavior_jwt"> line 33:           <webhttp/> line 34:           <messageinspector/> line 35:         </behavior> line 36:       </endpointbehaviors> 

you can't add messageinspector directly way, need implement iendpointbehavior behaviorextensionelement.

msdn has detailed example.


Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -