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を明示的に設定する必要があります。例えば:

BehaviorConfiguration = "ImpersonationBehaviour"

そうしないと、これは機能しません。これは、Silverlightアプリケーションまたはコンソールアプリケーションには必要ありません。

于 2012-07-09T19:32:46.607 に答える