我有一个客户端-服务器应用程序。我一直在使用 WsDualHttpBinding 进行回调,一切都很好。WCF 服务使用 x509Certificates。该应用程序将托管在组织的 Intranet 中。我选择在专用端口上配置 NetTcpBinding。WCF 服务在 NetworkService 上运行,并在登录 NetworkService 时访问 MSSQL Server DB。Wcf 服务托管在 IIS 中的网站上。
客户端的 app.config 如下所示
<configuration>
<system.net>
<connectionManagement>
<remove address="*" />
<add address="*" maxconnection="200" />
</connectionManagement>
</system.net>
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="certForClient">
<CustomBehaviorExtension />
<clientCredentials>
<serviceCertificate>
<authentication certificateValidationMode="None" revocationMode="NoCheck" />
</serviceCertificate>
<clientCertificate findValue="localhost" x509FindType="FindBySubjectName" storeLocation="CurrentUser" storeName="My" />
</clientCredentials>
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<netTcpBinding>
<binding closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
transactionFlow="true" transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" listenBacklog="3000" maxBufferPoolSize="2147483647"
maxBufferSize="2147483647" maxConnections="1500" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="2147483647" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="20:00:10" enabled="true" />
<security mode="Message">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://localhost/Service1.svc"
binding="netTcpBinding"
contract="SampleWCFProxy.IService1"
behaviorConfiguration="certForClient">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="net.tcp://localhost/Service2.svc"
binding="netTcpBinding"
contract="SampleWCFProxy.IService2"
behaviorConfiguration="certForClient">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
web.config 看起来像这样
<configuration>
<system.net>
<connectionManagement>
<remove address="*" />
<add address="*" maxconnection="200" />
</connectionManagement>
</system.net>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
transactionFlow="true" transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" listenBacklog="3000" maxBufferPoolSize="2147483647"
maxBufferSize="2147483647" maxConnections="1500" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="2147483647" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="20:00:10" enabled="true" />
<security mode="Message">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<behavior name="ApplicationFaults">
<ApplicationBehaviorExtension />
<CustomBehaviorExtension />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="MyServiceBehavior">
<serviceCredentials>
<serviceCertificate findValue="localhost" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" />
</serviceCredentials>
<serviceSecurityAudit auditLogLocation="Application" serviceAuthorizationAuditLevel="Failure" messageAuthenticationAuditLevel="SuccessOrFailure" />
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
<serviceThrottling maxConcurrentCalls="1500" maxConcurrentSessions="1500" maxConcurrentInstances="1500" />
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="MyServiceBehavior" name="SampleWCF.Services.Service1">
<endpoint address=""
binding="netTcpBinding"
contract="SampleWCF.Services.Contracts.IService1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:7860/Service1" />
</baseAddresses>
</host>
</service>
<service behaviorConfiguration="MyServiceBehavior" name="SampleWCF.Services.Service2">
<endpoint address=""
binding="netTcpBinding"
contract="SampleWCF.Services.Contracts.IService2">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:7860/Service2" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
</configuration>
IIS端是这样的
我查看了相关的配置帖子,但似乎都没有。
在这种情况下,会出现以下问题:
- 我究竟做错了什么?
- 应用程序池应该使用哪个用户访问数据库?