2011-03-21 81 views
2

因为我在Win 2003 Server上托管WCF服务时遇到了问题。 因为它在我的本地PC上正常工作。WCF Rest服务在2003上使用POST/JSON进行托管

如果我需要在Web配置中进行任何更改,请让我现在。文件。对于相同的。

'/'应用程序中的服务器错误。 IIS指定的身份验证方案'IntegratedWindowsAuthentication,Anonymous',但该绑定仅支持完全指定一个身份验证方案。有效的认证方案是摘要,协商,NTLM,基本或匿名。更改IIS设置,以便只使用单个身份验证方案。 描述:执行当前Web请求期间发生未处理的异常。请查看堆栈跟踪以获取有关该错误的更多信息以及源代码的位置。

异常详细信息:System.InvalidOperationException:IIS指定的认证方案'IntegratedWindowsAuthentication,Anonymous',但该绑定仅支持完全指定一个认证方案。有效的认证方案是摘要,协商,NTLM,基本或匿名。更改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 
+1

检查web.config中的绑定配置是否使用basichttp或wshttp绑定。 – Aravind 2011-03-21 11:48:29

回答

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> 

当然具有象使我能够运行WIN2K3服务器上的WCF REST服务安装.NET 3.5 SP1我的配置了设置。