Complete demo
In the previous WCF Service reconstruction record (I), we established a project. Here we established a simple client to call the WCF Service for testing, which is very simple.
This completed demo is complete. How can I port this service to IIS?
Start transferring the WCF host
To host WCF to IIS, we need to create a new web project in the solution to host the WCF Service. to host the WCF Service in the Web, we need to reference wcflib in the web.ProgramSet
We need an SVC file to connect to the WCF Service library. Therefore, we need to add an SVC file to the site. Because vs2010 will automatically provide the services and methods for this SVC, we do not need the default one provided by him, so we deleted the interface corresponding to this SVC andCodeThe implementation file only retains the newaddservice. SVC file.
We need to change the content of this SVC file and direct the services to our wcflib assembly.
After modifying the file content, you can view the SVC and find that the service is provided normally. However, after referencing the service to the client, you will find that it is bound to the default HTTP:
Next we will set the service provided by this SVC file to the TCP mode. First, modify the Web. config file of the webhost project.
Modify the Project Properties of webhost, use IIS to provide services, and create a virtual directory.
Make sure that the IIS website must support net. TCP and be executed in ASP. NET 4.0,
Then let's take a look at it in IIS after it is generated.
Now, the transformation has been successful.
However, because of our large number of services, it is impossible to add SVC files one by one and then delete them. This processing speed will delay the development progress. How can we use the SVC file to transfer the TCP Service, in the next article, we will try again.