访问WCF服务时,指定的域不存在或无法联系异常

时间:2013-09-18 19:28:29

标签: c# .net winforms wcf web-services

我正在运行Windows窗体客户端使用的WCF服务。我在服务器上使用Windows身份验证,WCF服务正常。除了一个函数之外,服务中实现的所有函数在客户端应用程序上都能正常工作。我检查了该函数的[DataContract][OperationContract]的服务代码,甚至我使用SvcLogViewer.exe检查了Svc日志。但该功能不断提高NullReferenceException。我从SvcLog找到的例外是

The specified domain either does not exist or could not be contacted

此功能在本地服务器上运行正常,但在远程服务器上运行正常。我想知道的是发生此异常的原因,以下是我的ServiceModel代码:

<system.serviceModel>
    <bindings>
      <customBinding>
        <binding name="Wrabind" closeTimeout="00:05:00" openTimeout="00:05:00" sendTimeout="00:25:00">
          <textMessageEncoding/>
          <security authenticationMode="SecureConversation" includeTimestamp="true" messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10">
            <localClientSettings maxClockSkew="00:30:00" />
            <localServiceSettings maxClockSkew="00:30:00" />
            <secureConversationBootstrap messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10">
              <localClientSettings maxClockSkew="00:30:00" />
              <localServiceSettings maxClockSkew="00:30:00" />
            </secureConversationBootstrap>
          </security>
          <httpTransport maxBufferPoolSize="20000000" maxReceivedMessageSize="20000000" allowCookies="true" maxBufferSize="20000000" />
        </binding>
      </customBinding>
    </bindings>
    <services>
      <service behaviorConfiguration="WCoreService.Service1Behavior" name="WCoreService.Service1">
        <endpoint address="http://subdomain.domain.com/service1.svc" binding="customBinding" bindingConfiguration="Wrabind" contract="WCoreService.IService1" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="WCoreService.Service1Behavior">
          <serviceMetadata httpGetEnabled="false" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment>
      <baseAddressPrefixFilters>
        <add prefix="http://subdomain.domain.com/" />
      </baseAddressPrefixFilters>
    </serviceHostingEnvironment>

  </system.serviceModel>

1 个答案:

答案 0 :(得分:0)

最后我自己解决了。在代码中有一些我无法找到的逻辑错误,但不知何故经历了整个控制流程,我发现这个小错误。该错误实际上是在客户端我在尚未创建服务连接的地方调用错误的服务功能。它是在代码中稍后创建的。所以我只是在调用之前将连接创建代码转移到了错误的服务功能,并且它工作正常。我希望有同样问题的人可能会觉得这个解决方案很有用。

相关问题