【问题标题】:How to avoid CommunicationObjectFaultedException when hosting a WCF service in IIS?在 IIS 中托管 WCF 服务时如何避免 CommunicationObjectFaultedException?
【发布时间】:2010-11-15 05:37:33
【问题描述】:

在创建WCF Web Service for IIS 并在我的 ASP.NET 开发服务器中成功对其进行测试后,当我将服务部署到 另一台机器的 IIS 时,它总是会在使用时触发以下异常:

测试方法 PoolingServiceTest.ProgramTest.MainTaskTest 抛出异常:System.ServiceModel.CommunicationObjectFaultedException: O object de comunicação, System.ServiceModel.Channels.ServiceChannel, não pod ser usado para comunicação porque está no estado Com Falha..

英文:The object cannot be used for communication because it is With Fault (故障)

堆栈跟踪

System.ServiceModel.Channels.CommunicationObject.Close(TimeSpan 超时) System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg,IMessage retMsg) System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData,Int32 类型) System.ServiceModel.ICommunicationObject.Close(时间跨度超时) System.ServiceModel.ICommunicationObject.Close(时间跨度超时) 关闭() System.IDisposable.Dispose()

我能做些什么来避免这种情况?

在客户端代码周围有一个 try catch 块,我得到了一个不同的异常:

[System.ServiceModel.Security.SecurityNegotiationException] {"O chamador não foi autenticado pelo serviço."} System.ServiceModel.Security.SecurityNegotiationException

英文:调用者未经服务验证

【问题讨论】:

    标签: .net asp.net wcf iis


    【解决方案1】:

    很明显,从您的第二条消息中,服务希望调用者进行身份验证。根据您使用的绑定(协议),这可能是以下几种方法之一:

    • Windows 身份验证:默认情况下,对于 wsHttp 和 netTcp 绑定,将使用用户的 Windows 帐户(这要求调用用户和被调用服务位于同一 Windows 域中,或至少位于受信任域中)

    • 针对 ASP.NET 成员身份的用户名/密码身份验证 - 这通常需要相当多的配置,因此我认为您不会“默认启用”

    • X.509 证书 - 再次,需要配置

    我的猜测是:您的 Web IIS 服务器不知何故无法正确理解/解释调用者的身份。该 IIS 服务器可能不是 Active Directory 域的成员吗?或者调用者的机器不是同一个域的成员?我想它一定是那个领域的东西。

    马克

    PS:
    要同时关闭安全性(不推荐! - 至少不适用于实际生产系统),您可以这样做:

    <bindings>
      <basicHttpBinding>
        <binding name="NoSecurity">
          <security mode="None" />
        </binding>
      </basicHttpBinding>
    

    然后在您的端点(服务器端和客户端)中引用该绑定配置:

    <endpoint address="....." 
              binding="basicHttpBinding" 
              bindingConfiguration="NoSecurity"
              contract="IMyService" />
    

    【讨论】:

    • 是的,我错过了第二部分。 :)
    • 有什么办法根本不需要任何身份验证?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-12-13
    • 2020-04-26
    • 1970-01-01
    • 2011-05-11
    • 2012-08-18
    • 2012-07-06
    相关资源
    最近更新 更多