从WSDualHttpBinding更改为NetTcpBinding似乎不起作用

时间:2017-08-19 17:20:23

标签: wcf x509certificate nettcpbinding wsdualhttpbinding

我有一个客户端 - 服务器应用程序。我一直在使用WsDualHttpBinding进行回调,一切都很顺利。 WCF服务使用x509Certificates。该应用程序将托管在组织内部网中。我选择在专用端口上配置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端看起来像这样

enter image description here 我查看了相关的posts配置,但似乎都没有。

从这种情况出现,这些问题出现了:

  1. 我做错了什么?
  2. 应用程序池应该使用哪个用户来访问数据库?

0 个答案:

没有答案