Host WCF Service in IIS8


Today I'm going to Show how to host a WCF Service in IIS in easy way. there are several approaches you can host WCF service to IIS. okay to host a service we need to create a Service right. so let's create a simple WCF Service.

1. Go to Visual Studio and create a new WCF Service Application Project.
 

2. Remove existing Methods from IService1 Interface and add below method to your project.
    Note : You can add any other method rather than my one.








3. Remove existing method from Service1 class and add below method implementation.









4. Cool now you have a simple service which you can host in IIS. before host it inside IIS check whether there is any error by building the solution ( Press F5)


5.  Next go to machines C: drive and create a folder (example : C:\WCF_IIS ) 
    Note : You can create a folder anyplace you like and This will be the physical folder which will run the          WCF service.

6.  Then create a bin folder in side WCF_IIS folder and copy following dlls to that folder. after build you solution you can find the required dlls in side your project bin folder.
                     - WcfService1.dll
   

7. Next go to the project folder and select following items and add those things to the WCF_IIS folder


                    -  Service1.svc
                    -  
Web.config
 
      


8. Now inside WCF_IIS folder is looks like this.








9. Then add following permission to WCF_IIS Folder

                   -  IIS_IUSRS : Read/Write permission 
                   -  Network Service : Read/Write Permssion     

10. Now go to the IIS Manager and Add an application Pool

         


         

Parameter Name

Value
   Name
<< You can  decide>>
  .Net Framework version
<version 4.0>
Managed pipeline mode

<Integrated>



   11. Okay now we need to create a Website to host our application

         

Parameter Name
Value
Site Name
<< You can decide>>
  Application Pool
This will be the application pool which was created in the previous step.
 Physical path
This will be the path of the WCF folder which was created earlier. Ex: (C:\WCF_IIS)
 Type
<< You candecide>>
 IP Address
<< You can decide>>
 Port
<< You can decide>>
Host name
<< You can decide>>

12. Great now we are almost there to the final. now try to run you service. by entering URL or else you can do it through IIS


13. And if you get an error. go to your web config file and remove those section and try it again.
   

     

14. Now you can consume your service through a client application. That's all for this post hope you learnt something from this. Happy coding and have a nice day guys.

Comments

Popular posts from this blog

Deep dive into OpenXML Part 1

Deep dive into OpenXML Part 2

Convert XML data to dynamic (ExpandoObject) Object