日期:2014-05-20  浏览次数:20780 次

WCF WindowServer服务 配置问题
WCF简单程序代码:
本地机器既做服务器也做客户端,服务宿主用WindowsServer 客户端WindowForm.
服务端appconfig配置文件入下:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>

  <connectionStrings>
  <add name="ValidDB" providerName="System.Data.SqlClient"
  connectionString="Data Source=.;Initial Catalog=ValidDB;Integrated Security=True"/>
  </connectionStrings>
  
  <system.serviceModel>
  <services> 
  <service name="ValidataInputDataERP.Service.DeptService" behaviorConfiguration="SampleBehavior">
  <endpoint address="" binding="wsHttpBinding" contract="ValidataInputDataERP.Contract.IDept" /> 
  <endpoint binding="mexHttpBinding" contract="IMetadataExchange" address="mex" />
  <host>
  <baseAddresses>
  <add baseAddress="http://localhost:1123/HostByWS/"/>
  </baseAddresses>
  </host>
  </service>
  </services>
  <behaviors>
  <serviceBehaviors>
  <behavior name="SampleBehavior">
  <serviceMetadata httpGetEnabled="True"/>
  <serviceDebug includeExceptionDetailInFaults="True" />
  </behavior>
  </serviceBehaviors>
  </behaviors>
  </system.serviceModel>
</configuration>

--------
客户端appconfig是通过添加引用服务自动生成的代码如下:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
  <bindings>
  <wsHttpBinding>
  <binding name="WSHttpBinding_IDept" closeTimeout="00:01:00" openTimeout="00:01:00"
  receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false"
  transactionFlow="false" hostNameComparisonMode="StrongWildcard"
  maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
  messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
  allowCookies="false">
  <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
  maxBytesPerRead="4096" maxNameTableCharCount="16384" />
  <reliableSession ordered="true" inactivityTimeout="00:10:00"
  enabled="false" />
  <security mode="Message">
  <transport clientCredentialType="Windows" proxyCredentialType="None"
  realm="" />
  <message clientCredentialType="Windows" negotiateServiceCredential="true"
  algorithmSuite="Default" establishSecurityContext="true" />
  </security>
  </binding>
  </wsHttpBinding>
  </bindings>
  <client>
  <endpoint address="http://localhost:1123/HostByWS/" binding="wsHttpBinding"