.netWCF

Hosting WCF service in iis(Part-21)

To Host a WCF service in iis,we will make use of same WCFSelfHostService webservice that we have created.

To host WCF service in iis:

  • Right click on solution–>Add–>new website–>WCF service–>Save it in same folder where we have WCFSelfHostService and name it WCFIISHost.
  • Delete cs files from appcode folder because we wanted to host existing service
  • Add reference to WCFSelfHostService from solution
  • Rename service1.svc to WCFIISHost.svc
  • open WCFIISHost.svc file and remove the codebehind attribute because our code is not there.
  • give the fully qualified name of service i.e. Service="WCFSelfHostService.WCFSelfHostService"
  • Specify the service end point url in web.config
  • in Run window, type inetmgr and it will open iis for you. expand root node and right click on default website and select Add application
  • Give an alias to the service and give the physical path and select application pool as ASP.net4.5
  • It will create the virtual directory for your service in iis. Then build solution
  • Then browse the service from inetmgr
  • Then you can test your client by adding service reference to wsdl document and test it

To host a wcf service in iis,you need to create a file with .svc extension.The service code can be present in .svc file or a separate assembly or in a file in App_code folder.The configuration for WCF service reside in web.config file.

© 2015, www.techkatak.com. All rights reserved.

One thought on “Hosting WCF service in iis(Part-21)

Comments are closed.