WCF Service Base Address Http and netTcp

前端 未结 2 1264
时光说笑
时光说笑 2021-02-08 11:08

I have two base addresses defined in my WCF Service config file:


      
  

        
2条回答
  •  后悔当初
    2021-02-08 11:36

    Due to not having answers clear enough , I decided to find out by my self the best solution. Here is what you have to do to configure a WCF NET TCP service endpoint in IIS 7.0.

    To achieve this, we need two steps:

    1. Configure a config file for WCF net tcp endpoint
    2. Configure IIS for net tcp

    1. Configure a config file for WCF net tcp endpoint

    Below is a typical config file, notice that the value for "address", in service's endpoint, is empty.

    Also notice that inside the node "host" Im adding 2 base addresses, an http and a net tcp protocols respectly. Since the service is hosted in IIS you don't have to worry about the absolute address in the endpoint, IIS figures this out based on the base address we have defined inside the node "host".

        
        
          
            
              
            
          
        
         
          
            
          
          
            
               
          
        
        
          
            
            
            
            
            
                
            
        
        
        
            
                
                            
                     
                     
                     
                   
                   
                
            
          
            
      
    

    2. Configure IIS for net tcp

    In IIS, (after updated your service with new configuration) enable the net.tcp protocol. These are the steps:

    • Open IIS.
    • In sites list, find your "site" where your wcf is hosted, then right-click on it
    • then, select "Edit Bindings",
    • a list of bindings appears (be sure that net.tcp is no there), then add your net.tcp configuration,
    • click "Add",
    • Type net.tcp (or select net.tcp from a dropdown list if it is available)
    • in binding Information type: 8090:* (make sure it's the same port as in host > base address you'd added)
    • then close this window and restart your service.

    After doing this, there is also another configuration:

    • Open IIS
    • In sites list, find your "site" where your wcf is hosted, then right-click on it
    • Click "Advanced Settings"
    • Select Enabled Protocols
    • Set the value to http,net.tcp (be sure that there are not blanks between http,net.tcp)
    • Restart your service

    Also, if you still cannot access service, you might need to start your Net.tcp listener adapter in your server. To achieve this, please follow next steps:

    • Go to ServerManager -> Configuration -> Services, stop the Net.Tcp Listener Adapter and the Net.Tcp Port Sharing Service. Then start them again.

    That's all you have to do to have a nettcp WCF endpoint enabled in IIS.

    Hope this helps.

    Regards

提交回复
热议问题