2

当我在 Win 2003 服务器上托管 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 
4

1 回答 1

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>

Certainly having my configuration set-up like that has enabled me to run a WCF REST service on Win2k3 server with .NET 3.5 SP1 installed.

于 2011-03-24T10:10:03.643 回答