Peter
Peter

Reputation: 1057

WCF custom ServiceHost on IIS

I'm trying to host my WCF service with a custom ServiceHost on IIS. I found a couple of articles on MSDN like this: Custom Service Host. Here, I'm supposed to add something to my services svc file, but I don't have one and I can't add one in visual studio either. Then I found this article: Configuration-Based Activation in IIS and WAS. This says

"The configuration-based activation feature removes the requirement to have a .svc file and therefore the associated overhead."

so I can just create a serviceHostingEnvironment entry in my Web.config (which I don't have either, but I guess App.config is equivalent since it contains my system.serviceModel configuration). However, I have to specify a relativeAddress for the service activation.

"The relativeAddress attribute must be set to a relative address such as <sub-directory>/service.svc or ~/<sub-directory/service.svc. "

So it should point to my svc file? I'm a bit confused, could you point me to the right direction?

Upvotes: 2

Views: 843

Answers (1)

Pankaj Kapare
Pankaj Kapare

Reputation: 7802

I know documentation on MSDN is little confusing. Here is configuration that you need to put in web.confi/app.config

<serviceHostingEnvironment>
  <serviceActivations>
    <add relativeAddress="MyNonExistingServiceSVC.svc" service="MyService" factory=”MyServiceHostFactory”/>
  </serviceActivations>
</serviceHostingEnvironment>

Here relative address will be just any dummy name. This name will be used to browse your service metadata. Please note that this name can be anything of your choice and it DOES NOT require same physical file to be present on disk. It just needs any name with .SVC extension. So while accessing service metadata your URL will be

http://myserver/myservice/MyNonExistingServiceSVC.svc

Upvotes: 1

Related Questions