因为我在Win 2003 Server上托管WCF服务时遇到问题。 因为它在我当地的PC上工作正常。
如果我需要在Web Config中进行任何更改,请立即告诉我。文件。同样的。
>'/'应用程序中的服务器错误。 IIS指定的身份验证方案“IntegratedWindowsAuthentication,Anonymous”,但绑定仅支持一种身份验证方案的规范。有效的身份验证方案是Digest,Negotiate,NTLM,Basic或Anonymous。更改IIS设置,以便仅使用单个身份验证方案。 描述:执行当前Web请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的详细信息。异常详细信息:System.InvalidOperationException:IIS指定的身份验证方案“IntegratedWindowsAuthentication,Anonymous”,但绑定仅支持一种身份验证方案的规范。有效的身份验证方案是Digest,Negotiate,NTLM,Basic或Anonymous。更改IIS设置,以便仅使用单个身份验证方案。
来源错误:
在执行当前Web请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪来识别有关异常的起源和位置的信息。
堆栈追踪:
[InvalidOperationException: IIS specified authentication schemes 'IntegratedWindowsAuthentication, Anonymous', but the binding only supports specification of exactly one authentication scheme. Valid authentication schemes are Digest, Negotiate, NTLM, Basic, or Anonymous. Change the IIS settings so that only a single authentication scheme is used.]
System.ServiceModel.Web.WebServiceHost.SetBindingCredentialBasedOnHostedEnvironment(ServiceEndpoint serviceEndpoint, AuthenticationSchemes supportedSchemes) +446264
System.ServiceModel.Web.WebServiceHost.AddAutomaticWebHttpBindingEndpoints(ServiceHost host, IDictionary`2 implementedContracts, String multipleContractsErrorMessage) +709
System.ServiceModel.Web.WebServiceHost.OnOpening() +203
Microsoft.ServiceModel.Web.WebServiceHost2.OnOpening() in e:\bt\3781\Microsoft.ServiceModel.Web\Microsoft.ServiceModel.Web\WebServiceHost2.cs:69
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +229
System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +121
System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +479
[ServiceActivationException: The service '/Service.svc' cannot be activated due to an exception during compilation. The exception message is: IIS specified authentication schemes 'IntegratedWindowsAuthentication, Anonymous', but the binding only supports specification of exactly one authentication scheme. Valid authentication schemes are Digest, Negotiate, NTLM, Basic, or Anonymous. Change the IIS settings so that only a single authentication scheme is used..]
System.ServiceModel.AsyncResult.End(IAsyncResult result) +11599786
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +194
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication context, Boolean flowContext) +176
System.ServiceModel.Activation.HttpModule.ProcessRequest(Object sender, EventArgs e) +278
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +68
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
Version Information: Microsoft .NET Framework Version:2.0.50727.3615; ASP.NET Version:2.0.50727.3618
答案 0 :(得分:3)
有一个快速修复和正确的修复。
快速修复:
在IIS中,转到运行该服务的Web应用程序的属性,转到“目录安全性”选项卡,然后在“身份验证和访问控制”组中,按“编辑...”。删除您不需要的任何身份验证方案。确定所有对话框,然后执行IIS重置。
正确修复:
确保您的服务配置为使用显式端点。我发现使用webHttpBinding
开箱即用的绑定,并将端点配置为使用webHttp
行为就是诀窍。
如果您没有指定端点,WebserviceHost将尝试猜测您想要的内容,并且总是选错了。
在你的web.config中,你应该有:
<system.serviceModel>
<services>
<service behaviourConfiguration="MyRestService.Behavior"
name="MyRestService>
<endpoint address="" binding="webHttpBinding" contract="IMyRestService"
behaviourConfiguration="MyRestService.WebHttpEndpointBehavior" />
</service>
</services>
<bindings>
</bindings>
<behaviours>
<serviceBehaviors>
<behavior name="MyRestService.Behavior">
<!-- Any configuration for the service, i.e. serviceDebug, etc. -->
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="MyRestService.WebHttpEndpointBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviours>
</system.serviceModel>
当然,我的配置设置使我能够在安装了.NET 3.5 SP1的Win2k3服务器上运行WCF REST服务。