简体   繁体   English

在.svc上具有Factory属性的WCF服务在Web服务器(IIS6)上不起作用,但在本地使用IIS7?

[英]WCF service with Factory attribute on .svc is not working on web server (IIS6), but is locally using IIS7?

I am working on implementing a non web.config approach of WCF services using the factory attribute on the .svc file per Rick Strahl's blog post : 我正在使用.svc文件中的工厂属性实现WCF服务的非web.config方法,根据Rick Strahl的博客文章

Factory="System.ServiceModel.Activation.WebScriptServiceHostFactory" 工厂= “System.ServiceModel.Activation.WebScriptServiceHostFactory”

Locally, I am running IIS7 in Visual Studio 2008 and have no problem, but when I deploy to my web server (currently running IIS6), I am getting an authentication error in the event log: 在本地,我在Visual Studio 2008中运行IIS7并没有问题,但是当我部署到我的Web服务器(当前运行IIS6)时,我在事件日志中收到身份验证错误:

Exception: System.ServiceModel.ServiceActivationException: The service '/Services/ResourcesService.svc' cannot be activated due to an exception during compilation. 异常:System.ServiceModel.ServiceActivationException:由于编译期间发生异常,无法激活服务'/Services/ResourcesService.svc'。 The exception message is: IIS specified authentication schemes 'IntegratedWindowsAuthentication, Anonymous', but the binding only supports specification of exactly one authentication scheme. 异常消息是:IIS指定的身份验证方案“IntegratedWindowsAuthentication,Anonymous”,但绑定仅支持一种身份验证方案的规范。 Valid authentication schemes are Digest, Negotiate, NTLM, Basic, or Anonymous. 有效的身份验证方案是Digest,Negotiate,NTLM,Basic或Anonymous。 Change the IIS settings so that only a single authentication scheme is used.. ---> System.InvalidOperationException: IIS specified authentication schemes 'IntegratedWindowsAuthentication, Anonymous', but the binding only supports specification of exactly one authentication scheme. 更改IIS设置,以便只使用一个身份验证方案.. ---> System.InvalidOperationException:IIS指定的身份验证方案“IntegratedWindowsAuthentication,Anonymous”,但绑定仅支持一个身份验证方案的规范。 Valid authentication schemes are Digest, Negotiate, NTLM, Basic, or Anonymous. 有效的身份验证方案是Digest,Negotiate,NTLM,Basic或Anonymous。 Change the IIS settings so that only a single authentication scheme is used. 更改IIS设置,以便仅使用单个身份验证方案。 at System.ServiceModel.Web.WebServiceHost.SetBindingCredentialBasedOnHostedEnvironment(ServiceEndpoint serviceEndpoint, AuthenticationSchemes supportedSchemes) at System.ServiceModel.Web.WebServiceHost.AddAutomaticWebHttpBindingEndpoints(ServiceHost host, IDictionary`2 implementedContracts, String multipleContractsErrorMessage) at System.ServiceModel.WebScriptServiceHost.OnOpening() at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) at System.ServiceModel.Channels.CommunicationObject.Open() at System.ServiceModel.ServiceHostingEnvironment.HostingManager.ActivateService(String normalizedVirtualPath) at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) System.ServiceModel.Web上的System.ServiceModel.Web.WebServiceHost.SetBindingCredentialBasedOnHostedEnvironment(ServiceEndpoint serviceEndpoint,AuthenticationSchemes supportedSchemes)处于System.ServiceModel.WebScriptServiceHost.OnOpening()的System.ServiceModel.Web.WebServiceHost.AddAutomaticWebHttpBindingEndpoints(ServiceHost主机,IDictionary`2已实现的字符串,String multipleContractsErrorMessage)处位于System.ServiceModel.ServiceHostingEnvironment.HostingManager.ActivateService(String normalizedVirtualPath)的System.ServiceModel.Channels.CommunicationObject.Open()处的System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout),System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable( String normalizedVirtualPath)

After doing some Googling, I changed my authentication settings on the .svc folder within my project (on the server) to only anonymous authentication, but it did not work. 在做了一些谷歌搜索后,我将我的项目(在服务器上)的.svc文件夹上的身份验证设置更改为仅匿名身份验证,但它不起作用。 I still get web service failed on the calls. 我仍然在通话时遇到网络服务失败。 IIS7 by default only had anonymous. IIS7默认只有匿名。

I do not have any entries in my web.config for the services (I stripped them out per this pattern). 我的web.config中没有任何条目用于服务(我按照这种模式剥离了它们)。

I am using a nant script to deploy the website to the server and use this also locally to verify the script was not causing the issue. 我正在使用一个nant脚本将网站部署到服务器,并在本地使用它来验证脚本不会导致问题。

Any known issue with this? 这个有任何已知问题吗? IIS 6 not able to handle? IIS 6无法处理?

I got this error ... 我收到了这个错误......

Checked my web site properties in IIS Manager and found both Anonymous and Integrated Windows Authentication were ticked, so un-ticked Integrated, but it still wouldn't work. 在IIS管理器中检查了我的网站属性,发现匿名和集成Windows身份验证都被勾选,因此未勾选集成,但它仍然无效。

Eventually spotted a post that mentioned restarting IIS ... did that and things worked !! 最终发现了一篇提到重启IIS的帖子......做到了这一点,事情有效!

The major difference between IIS 6 and IIS 7 with respect to WCF is the bindings that they support. IIS 6和IIS 7之间在WCF方面的主要区别在于它们支持的绑定。 For example IIS 6 supports basichttpbinding but not nettcpbinding. 例如,IIS 6支持basichttpbinding但不支持nettcpbinding。

The other thing to watch out for is if IIS 6 is configured to serve .svc files, that minimum .net framework 3.0 is installed. 另外需要注意的是,如果IIS 6配置为提供.svc文件,则安装最小的.net framework 3.0。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM