3

我想我应该去点形式:

  • 我有一项服务,用于在服务器端进行数据库调用

  • 使用 IIS

  • DBMS = SQL Server 2008 R2

  • 我的连接字符串没有问题,我有正确的凭据

  • 我这样做是随机连接到数据库的(这很有效......类在这里连接):

      using (Database db = base.SystemDatabase())
    
  • 上面的行并不总是成功。

  • 如果我最终连接,当我设置我的 SqlCommand 时它会中断。

这是我的 WCF 服务的配置:

<customBinding>
   <binding name="CustomBinding_ITestDataService">
      <binaryMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
                             maxSessionSize="2048">
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
   </binaryMessageEncoding>
   <httpTransport manualAddressing="false" maxBufferPoolSize="524288"
                  maxReceivedMessageSize="65536" allowCookies="false" 
                  authenticationScheme="Negotiate" bypassProxyOnLocal="false" 
                  hostNameComparisonMode="StrongWildcard"
                  keepAliveEnabled="true" maxBufferSize="65536" 
                  proxyAuthenticationScheme="Anonymous"
                  realm="" transferMode="Buffered" 
                  unsafeConnectionNtlmAuthentication="false" useDefaultWebProxy="true" />
   </binding>
</customBinding>
<behaviors>
   <endpointBehaviors>
      <behavior name="ImpersonationBehaviour">
         <clientCredentials>
             <windows allowedImpersonationLevel="Impersonation"/>
         </clientCredentials>
      </behavior>
   </endpointBehaviors>
</behaviors>
<client>
   <endpoint name="CustomBinding_ITestDataService"
       address="http://test.net/TestApp/TestDataService.svc"
       binding="customBinding" bindingConfiguration="CustomBinding_ITestDataService"
       contract="TestDataService.ITestDataService" >
       <identity>
           <servicePrincipalName value="host/Test.net" />
       </identity>
   </endpoint>
</client>

我会试着看看我是否能得到确切的错误信息......

编辑

感谢您的输入。我一直在解决这个问题,当我进行 wcf 调用然后进行远程调用然后给我一个

{"The requested name is valid, but no data of the requested type was found"}
    [System.Net.Sockets.SocketException]: {"The requested name is valid, but no data of the requested type was found"}
    Data: {System.Collections.ListDictionaryInternal}
    HelpLink: null
    InnerException: null
    Message: "The requested name is valid, but no data of the requested type was found"
    Source: "mscorlib"
    StackTrace: "\r\nServer stack trace: \r\n   at System.Net.Dns.InternalGetHostByName(String hostName, Boolean includeIPv6)\r\n   at System.Net.Dns.GetHostAddresses(String hostNameOrAddress)\r\n   at System.Runtime.Remoting.Channels.RemoteConnection.CreateNewSocket()\r\n   at System.Runtime.Remoting.Channels.SocketCache.GetSocket(String machinePortAndSid, Boolean openNew)\r\n   at System.Runtime.Remoting.Channels.Tcp.TcpClientTransportSink.SendRequestWithRetry(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream)\r\n   at System.Runtime.Remoting.Channels.Tcp.TcpClientTransportSink.ProcessMessage(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream, ITransportHeaders& responseHeaders, Stream& responseStream)\r\n   at System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessage(IMessage msg)\r\n\r\nException rethrown at [0]: \r\n   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)\r\n   at System.Runtime.Remoting.
Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)\r\n   at 

编辑 2

在我继续调查这个问题之后,这不是 WCF 的问题。在运行时,WCF 服务按其应有的方式工作。实际问题是 WCF 服务正在尝试调用数据库,但是当我尝试连接时,我得到一个 DNS 名称是有效的,但是找不到请求类型错误。

我的应用程序 -> WCF 服务 -> 连接到数据库 -> 运行查询 -> 返回值

4

1 回答 1

2

在 app.config 文件中,我们必须在端点中显式设置 behaviorConfiguration。例如:

行为配置="模拟行为"

否则,这将行不通。Silverlight 应用程序或控制台应用程序不需要这

于 2012-07-09T19:32:46.607 回答