WCF Service reconstruction record (medium)

Source: Internet
Author: User
Tags webhost
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.