WCF配置

第一次用WCF配置有点麻烦,看到这篇文章总结的不错就贴过来分享下!原文链接

http://goneale.com/2010/04/01/error-connecting-to-was-enabled-net-tcp-wcf-service-hosted-through-iis/

Error connecting to WAS-enabled Net Tcp WCF Service Hosted Through IIS

As you may be aware, setting up a TCP-based full duplex WCF service can have some pretty awesome advantages over regular HTTP-based WCF services, such as the ability for a true client/server persistent connection and the ability for the server to call back to the client at any time and there are a few good guides here and here on how to use them, but they have proven to have some real teething problems through setup.. So if you are attempting to host a WAS-enabled WCF service in IIS 7 using the net.tcp binding for duplex communication, and suffering from any connectivity or setup issues, particularly this one.. read on.

Could not connect to net.tcp://127.0.0.1/WCFService/Service1.svc.
The connection attempt lasted for a time span of 00:00:01.0464395.
TCP error code 10061: No connection could be made because the target machine actively refused it 127.0.0.1:808.

Check to ensure you have ticked off the below steps (as I went through them all!) when I encountered my issue connecting via a net.tcp:// WCF service today:

  1. Ensure you are running IIS 7. IIS 6 and below does not support Windows Process Activation Services (WAS) which boils down to no other binding support except for http (such as net.tcp).
    1. If you receive an error installing this component in Windows Features (like I did, I pretty much got every error possible setting all this up), it’s probably because you have the .NET Framework 4 installed (hmz – RC in my case), you know you shouldn’t have this installed! How dare you! So to get the component installed, .NET Framework 4 must be uninstalled (and all traces of it), the non-http activation component then installed, and then .NET Framework 4 reinstalled.  I tried a way to avoid this, but no luck; I found it was the only way the darn thing it would install.
    2. If everything has gone down the tubes even more, and now even your regular WCF services aren’t loading at all, and you’re encountering a MIME type error in the browser, it’s probably because attempting to install the windows feature borked it when it didn’t work first time and took down half of the WCF IIS configuration with it.  So see my previous post on how to fix a corrupt WCF IIS configuration.
  2. Double check that you have your WCF Service hosted and activated in IIS correctly, here is a great guide provided by SingingEels.
    1. This includes enabling “Windows Communication Foundation Non-HTTP Activation” via. Control Panel -> Programs and Features -> Turn Windows features on or off (under .NET Framework option).
    2. Ensuring the “Net.Tcp Protocol” in your web site is enabled under: IIS (7.0) Admin -> Right Click on your Web Site -> Manage Website -> Advanced Settings… (The ‘Enabled Protocols’ field should be set as http,net.tcp.  Note that is a comma, then a dot.)
    3. Then finally, Configure the “Site Bindings” in IIS. (Double check the port you are using, if it’s 808:* your service will be accessible under net.tcp://localhost/MyServices/Service1.svc, but if it’s 12345:* for example, or any other custom port, make sure you address it as such in your Web/App.config for your client connection as net.tcp://localhost:12345/MyServices/Service1.svc.
  3. Thirdly, try loading it now – if you are still receiving an error and you had to follow step 2.1 and had to activate the “Windows Communication Foundation Non-HTTP Activation” component and HAVE NOT rebooted since yet (lol), go into your local services and start the service entitled “Net.Tcp Listener Adapter“.  Fun and games.  That last point 3 was the one that really got me. As described it “Receives activation requests over the net.tcp protocol and passes them to the Windows Process Activation Service.”, Windows kindly forgot to turn that on after I had installed the component in Program Features.

That should be it, I didn’t encounter any other problem, so I hope you don’t either. I had no firewall issues so it shouldn’t ever be that.

Good luck.

posted @ 2012-02-15 18:38  幸运的程序员  阅读(476)  评论(0编辑  收藏  举报