I have already introduced the basic knowledge of WCF in my previous blog and made a simple example. If you read the previous blog, I believe you have some knowledge about WCF. This blog mainly describes how to publish the WCF Service on the IIS server.
In the demo we made in the previous blog, we wrote a server and used winform to publish the WCF Service. However, in actual projects, we cannot start this program window forever. Since it is a server, it should be in the server, as a "service", "Silently" for us to work!
As a member of the Windows family, IIS is always the first server on the. NET platform. The following describes how to publish the WCF Service to IIS.
Take the demo we made in the previous blog as an example. We publish it to IIS.
The general idea is to publish the WCF Service as a website, so we can access the WCF Service through the HTTP protocol!
Start!
1. Install related Windows functions
Of course, to publish a website, IIS and related functional services must be installed first.
In addition, you also need to install the. NET Framework Version and install the wcf http activation.
2. Create a root directory and set root directory permissions.
First, create a folder on a drive (my desktop) to serve as the root directory of our Publishing Service. Then set the ACL for this folder:
Right-click and choose Properties> Security. Set the user to allow access.
3. Copy the DLL file to the root directory.
Copy the bin folder in the project to the root directory.
Copy web. config to the root directory
Copy userserviceimpl. SVC to the root directory.
Remember to point the host in userserviceimpl. SVC to the modification:
<span style="white-space:pre"></span><%@ ServiceHost Language="C#" Debug="true" Service="WcfServiceDemo.UserServiceImpl" CodeBehind="UserServiceImpl.svc.cs" %>
4. Publish a website
Open IIS, right-click "website"> Add website> enter the relevant information and click "OK" to complete the release.
Specify userserviceimpl. SVC as the default document.
5. Verify release
At this point, we have successfully released the WCF to IIS. Now you can verify whether the release is successful.
Enter the address and port number you specified when adding the website in the browser. If the page appears, congratulations!
Of course, there may be various problems in the publishing process, but don't worry. These problems are common problems in the website publishing process. You only need to follow the prompts to find the error online, it is easy to solve.
So far, we have completed service provision after basic content introduction, the completion of small demo, and the release of WCF in IIS. Others can enjoy your services through HTTP!