0

我正在运行由 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>
4

1 回答 1

0

最后我自己解决了。代码中有一些我无法找到的逻辑错误,但是通过整个控制流程我发现了那个小错误。错误实际上是在客户端,我在尚未创建服务连接的地方调用了错误的服务功能。它是稍后在代码中创建的。所以我只是在调用错误的服务函数之前将连接创建代码转移了,它起作用了。我希望有同样问题的人会发现这个解决方案很有用。

于 2013-09-19T19:54:06.430 回答