wcf - Does using a custom ServiceHost disable simplified configuration? -


i have one-time initialization tasks on service startup, , in order have defined custom servicehostfactory , servicehost override initializeruntime.

service1.svc markup:

<%@ servicehost language="c#" debug="true" factory="service.our_service_host_factory" service="service.service1" codebehind="service1.svc.cs" %> 

service host definitions:

public class our_service_host_factory : servicehostfactory {     protected override servicehost createservicehost(type servicetype, uri[] baseaddresses)     {         return new our_service_host(servicetype, baseaddresses);     } }  class our_service_host : servicehost {     public our_service_host(type servicetype, uri[] baseaddresses)         : base(servicetype, baseaddresses) { }      protected override void initializeruntime()     {          // 1 time setup code     } } 

snippet web.config:

<system.servicemodel>   <behaviors>     <servicebehaviors>       <behavior>         <servicemetadata httpgetenabled="true" httpsgetenabled="true"/>         <servicedebug includeexceptiondetailinfaults="false"/>       </behavior>     </servicebehaviors>   </behaviors>   <protocolmapping>     <add binding="basichttpsbinding" scheme="https" />   </protocolmapping>       <servicehostingenvironment aspnetcompatibilityenabled="true" multiplesitebindingsenabled="true" /> </system.servicemodel> 

if remove factory attribute on servicehost markup, wcf test client can connect service. if put in, can't find metadata endpoint following error:

error: cannot obtain metadata http://localhost:50154/service1.svc if windows (r) communication foundation service have access, please check have enabled  metadata publishing @ specified address.  enabling metadata publishing, please  refer msdn documentation @ http://go.microsoft.com/fwlink/?linkid=65455.ws-metadata  exchange error    uri: http://localhost:50154/service1.svc    metadata contains reference  cannot resolved: 'http://localhost:50154/service1.svc'.    there no endpoint listening @  http://localhost:50154/service1.svc accept message. caused  incorrect address or soap action. see innerexception, if present, more details.     remote server returned error: (404) not found.http error    uri:  http://localhost:50154/service1.svc    there error  downloading 'http://localhost:50154/service1.svc'.    request failed http status 404:  not found. 

it looks having custom servicehost/servicehostfactory might break simplified configuration. case, or there i'm overlooking make continue work?

if override initializeruntime(), make sure call base.initializeruntime() or may see behavior. after calling base.initializeruntime() before calling additional startup logic, service being correctly routed to.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -