我有一个客户端/服务器应用程序,我正在尝试使用我创建的WCF服务,但它一直在抛出异常,我没有设法解决它!
这是WCF服务器的代码:
<configuration>
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true">
<services>
<service name="ChatService.ChatService"
behaviorConfiguration="behaviorConfig">
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:7997/Host/"/>
<add baseAddress="http://localhost:7998/Host/"/>
</baseAddresses>
</host>
<endpoint address="tcp"
binding="netTcpBinding"
bindingConfiguration="tcpBinding"
contract="ChatService.IChat"/>
<endpoint address="net.tcp://localhost:7996/Host/mex"
binding="mexTcpBinding"
contract="IMetadataExchange"/>
</service>
</services>
</serviceHostingEnvironment>
<behaviors>
<serviceBehaviors>
<behavior name="behaviorConfig">
<serviceMetadata httpGetEnabled="true" httpGetUrl=""/>
<serviceDebug includeExceptionDetailInFaults="false"/>
<serviceThrottling maxConcurrentCalls="100" maxConcurrentSessions="100"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<netTcpBinding>
<binding name="tcpBinding"
maxBufferSize="67108864"
maxReceivedMessageSize="67108864"
maxBufferPoolSize="67108864"
transferMode="Buffered"
closeTimeout="00:00:10"
openTimeout="00:00:10"
receiveTimeout="00:20:00"
sendTimeout="00:01:00"
maxConnections="100">
<security mode="None">
</security>
<readerQuotas maxArrayLength="67108864"
maxBytesPerRead="67108864"
maxStringContentLength="67108864"/>
<reliableSession enabled="true" inactivityTimeout="00:20:00"/>
</binding>
</netTcpBinding>
</bindings>
</system.serviceModel>
</configuration>
这是客户的WCF服务:
<configuration>
<connectionStrings>
<add name="IClient.Properties.Settings.Co_WorkersDataBaseConnectionString"
connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\Co-WorkersDataBase.mdb"
providerName="System.Data.OleDb" />
</connectionStrings>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_IChat" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" transactionFlow="false"
transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" listenBacklog="10"
maxBufferPoolSize="67108864" maxBufferSize="67108864" maxConnections="100"
maxReceivedMessageSize="67108864">
<readerQuotas maxDepth="32" maxStringContentLength="67108864" maxArrayLength="67108864"
maxBytesPerRead="67108864" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="20:00:10"
enabled="true" />
<security mode="None">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://localhost:7997/Host/tcp" binding="netTcpBinding"
bindingConfiguration="NetTcpBinding_IChat" contract="CHATSERVICE.IChat"
name="NetTcpBinding_IChat" />
</client>
</system.serviceModel>
</configuration>
我正在尝试做的是与服务器建立连接,但我得到的只是例外!!
服务器没有提供有意义的回复,这可能是由此引起的 合同不匹配,过早会话关闭或内部 服务器错误
Server stack trace:
at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeEndService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at IClient.CHATSERVICE.IChat.EndConnect(IAsyncResult result)
at IClient.CHATSERVICE.ChatClient.EndConnect(IAsyncResult result) in C:\Users\Desktop\IClient\Service References\CHATSERVICE\Reference.cs:line 641
at IClient.CHATSERVICE.ChatClient.OnEndConnect(IAsyncResult result) in C:\Users\Desktop\IClient\Service References\CHATSERVICE\Reference.cs:line 652
at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result)
PS:当我点击客户端应用程序的连接按钮时,我收到此异常, 服务器与客户端应用程序同时运行。
请帮助!!
答案 0 :(得分:0)
服务器上的安全性是无,但客户端上的客户端凭证类型窗口存在消息安全性 - 这些需要匹配。