wif - Why WCF custom ServiceHostFactory getting called every time? -


i have wcf service (hosted in iis 7.5) has svc file less activation using following

<servicehostingenvironment>     <serviceactivations>       <add factory="string"            service="string"/>    </serviceactivations> </servicehostingenvironment> 

i using custom host factory not default one.

and service wstrustservicecontract. if see declaration of class

[servicebehaviorattribute(name = "securitytokenservice", namespace = "http://schemas.microsoft.com/ws/2008/06/identity/securitytokenservice",      instancecontextmode = instancecontextmode.single, concurrencymode = concurrencymode.multiple)] [aspnetcompatibilityrequirementsattribute(requirementsmode = aspnetcompatibilityrequirementsmode.allowed)] public class wstrustservicecontract : iwstrustfeb2005synccontract,      iwstrust13synccontract, iwstrustfeb2005asynccontract, iwstrust13asynccontract, iwsdlexportextension, icontractbehavior 

so can infer that

  1. the custom host factory called create instance of service.
  2. once service instance created, there requests (instancecontextmode.single)

my questions are

  1. why instance of custom host factory getting created per call (i have breakpoint in constructor of factory. debugging attaching w3wc instance) ?
  2. why instance of service getting created per call?

as said, created simple application , worked correctly. try compare that:

servicehost

public class myservicehost     inherits servicehost      public sub new(servicetype type, baseaddresses uri())         mybase.new(servicetype, baseaddresses)     end sub  end class  public class myservicehostfactory     inherits servicehostfactory      public sub new()         trace.traceinformation("myservicehost instance created.")     end sub      protected overrides function createservicehost(servicetype type, baseaddresses uri()) servicehost         return new myservicehost(servicetype, baseaddresses)     end function  end class 

service

<servicecontract> public interface iservice      <operationcontract()>     function sayhello(name string) string  end interface  <servicebehavior(instancecontextmode:=instancecontextmode.single, concurrencymode:=concurrencymode.multiple)> <aspnetcompatibilityrequirements(requirementsmode:=aspnetcompatibilityrequirementsmode.allowed)> public class service     implements iservice      public sub new()         trace.traceinformation("service instance created.")     end sub      public function sayhello(name string) string implements iservice.sayhello         trace.traceinformation("calling service.sayhello({0}).", name)         return "hello " & name     end function  end class  public class global_asax     inherits httpapplication      sub application_start(byval sender object, byval e eventargs)         trace.traceinformation("application started")     end sub  end class 

web.config

<system.servicemodel>     <behaviors>         <servicebehaviors>             <behavior>                 <servicemetadata httpgetenabled="true" />             </behavior>         </servicebehaviors>     </behaviors>     <servicehostingenvironment aspnetcompatibilityenabled="true" multiplesitebindingsenabled="true">         <serviceactivations>             <add factory="filelessactivationwithcustomservicehost.myservicehostfactory"                  service="filelessactivationwithcustomservicehost.service"                   relativeaddress="service.svc"/>         </serviceactivations>     </servicehostingenvironment> </system.servicemodel>  <system.diagnostics>     <trace autoflush="true" indentsize="4">         <listeners>             <remove name="default" />             <add name="default"                  type="system.diagnostics.xmlwritertracelistener"                  initializedata="log.svclog" />         </listeners>     </trace> </system.diagnostics> 

i started web application, made several calls of sayhello function , can see bellow, behaves correctly: enter image description here


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -