Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wcf 以编程方式创建带有证书的netTcp绑定_Wcf_Tcp_Nettcpbinding - Fatal编程技术网

Wcf 以编程方式创建带有证书的netTcp绑定

Wcf 以编程方式创建带有证书的netTcp绑定,wcf,tcp,nettcpbinding,Wcf,Tcp,Nettcpbinding,我有一个WCF.NETV4的通用托管服务。它允许以插件方式删除多个代理,每个代理都有自己的配置文件。它是作为服务编写的,因为所有站点都没有IIS或已安装,但我们可以指定.net v4和我们的custome服务 <netTcpBinding> <binding name="NetTcpEndPoint_ISolutionsDataAccessorV01" closeTimeout="00:01:00" ope

我有一个WCF.NETV4的通用托管服务。它允许以插件方式删除多个代理,每个代理都有自己的配置文件。它是作为服务编写的,因为所有站点都没有IIS或已安装,但我们可以指定.net v4和我们的custome服务

        <netTcpBinding>
            <binding name="NetTcpEndPoint_ISolutionsDataAccessorV01" 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="524288" maxBufferSize="65536" maxConnections="10"
                maxReceivedMessageSize="65536">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <reliableSession ordered="true" inactivityTimeout="00:10:00"
                    enabled="false" />
                <security mode="Transport">
                    <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
                    <message clientCredentialType="Windows" />
                </security>
            </binding>
        </netTcpBinding>

    </bindings>
    <client>
        <endpoint address="net.tcp://localhost:1177/TcpService" binding="netTcpBinding"
            bindingConfiguration="NetTcpEndPoint_ISolutionsDataAccessorV01"
            contract="sDAL.ISolutionsDataAccessorV01" name="NetTcpEndPoint_ISolutionsDataAccessorV01">
            <identity>
                <userPrincipalName value="abc@xyz.com" />
            </identity>
        </endpoint>
    </client>
</system.serviceModel>
<behaviors>
  <serviceBehaviors>
    <behavior name="SolutionsDALServiceBehavior">
   <serviceCredentials>
     <serviceCertificate findValue="STSTestCert"
                         x509FindType="FindByIssuerName" />
   </serviceCredentials>
    <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
      <!-- <serviceMetadata httpGetEnabled="true"/> -->
      <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="true"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
没有凭据的HTTP、HTTPS或TCP没有问题。当我们向服务器添加证书时,它似乎启动时没有问题。一旦我们试图呼叫服务,我们就会得到一个频道故障。我们编写了一个小型的自托管程序,它使用配置文件,而不是以编程方式创建端点,并且工作起来没有任何问题。我们只能推测我们错过了一个场景,但无法确定是哪个场景

        <netTcpBinding>
            <binding name="NetTcpEndPoint_ISolutionsDataAccessorV01" 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="524288" maxBufferSize="65536" maxConnections="10"
                maxReceivedMessageSize="65536">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <reliableSession ordered="true" inactivityTimeout="00:10:00"
                    enabled="false" />
                <security mode="Transport">
                    <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
                    <message clientCredentialType="Windows" />
                </security>
            </binding>
        </netTcpBinding>

    </bindings>
    <client>
        <endpoint address="net.tcp://localhost:1177/TcpService" binding="netTcpBinding"
            bindingConfiguration="NetTcpEndPoint_ISolutionsDataAccessorV01"
            contract="sDAL.ISolutionsDataAccessorV01" name="NetTcpEndPoint_ISolutionsDataAccessorV01">
            <identity>
                <userPrincipalName value="abc@xyz.com" />
            </identity>
        </endpoint>
    </client>
</system.serviceModel>
<behaviors>
  <serviceBehaviors>
    <behavior name="SolutionsDALServiceBehavior">
   <serviceCredentials>
     <serviceCertificate findValue="STSTestCert"
                         x509FindType="FindByIssuerName" />
   </serviceCredentials>
    <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
      <!-- <serviceMetadata httpGetEnabled="true"/> -->
      <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="true"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
我们得到的错误如下所示。似乎由于某种原因,客户端正在尝试设置双通道tcp连接,而我们没有在主机中配置该连接

Protocol Type application/negotiate was sent to a service that does not support that type of upgrade.
System.ServiceModel.Channels.ServerSessionPreambleConnectionReader.ServerFramingDuplexSessionChannel.ProcessUpgradeRequest(TimeoutHelper&amp; timeoutHelper)
System.ServiceModel.Channels.ServerSessionPreambleConnectionReader.ServerFramingDuplexSessionChannel.OnOpen(TimeSpan timeout)
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
System.ServiceModel.Channels.CommunicationObject.Open()
System.ServiceModel.Channels.ReliableChannelListener`3.HandleAcceptComplete(TInnerChannel channel)
System.ServiceModel.Channels.ReliableChannelListener`3.OnAcceptCompleted(IAsyncResult result)
System.ServiceModel.Channels.ReliableChannelListener`3.OnAcceptCompletedStatic(IAsyncResult result)
System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result)
System.ServiceModel.Diagnostics.TraceUtility.&lt;&gt;c__DisplayClass4.&lt;CallbackGenerator&gt;b__2(AsyncCallback callback, IAsyncResult result)
System.Runtime.AsyncResult.Complete(Boolean completedSynchronously)
System.Runtime.InputQueue`1.AsyncQueueReader.Set(Item item)
System.Runtime.InputQueue`1.EnqueueAndDispatch(Item item, Boolean canDispatchOnThisThread)
System.Runtime.InputQueue`1.EnqueueAndDispatch(T item, Action dequeuedCallback, Boolean canDispatchOnThisThread)
System.ServiceModel.Channels.TcpDuplexChannelListener.System.ServiceModel.Channels.ISessionPreambleHandler.HandleServerSessionPreamble(ServerSessionPreambleConnectionReader preambleReader, ConnectionDemuxer connectionDemuxer)
System.ServiceModel.Channels.ConnectionOrientedTransportManager`1.OnHandleServerSessionPreamble(ServerSessionPreambleConnectionReader serverSessionPreambleReader, ConnectionDemuxer connectionDemuxer)
System.ServiceModel.Channels.ConnectionDemuxer.OnSessionPreambleKnown(ServerSessionPreambleConnectionReader serverSessionPreambleReader)
System.ServiceModel.Channels.ServerSessionPreambleConnectionReader.ContinueReading()
System.ServiceModel.Channels.ServerSessionPreambleConnectionReader.StartReading(Action`1 viaDelegate, TimeSpan receiveTimeout)
System.ServiceModel.Channels.ConnectionDemuxer.OnDuplexConnection(IConnection connection, Action connectionDequeuedCallback, Int64 streamPosition, Int32 offset, Int32 size, TimeSpan timeout)
System.ServiceModel.Channels.ConnectionDemuxer.OnConnectionModeKnownCore(ConnectionModeReader modeReader, Boolean isCached)
System.ServiceModel.Channels.ConnectionDemuxer.OnConnectionModeKnown(ConnectionModeReader modeReader)
System.ServiceModel.Channels.ConnectionModeReader.Complete()
System.ServiceModel.Channels.ConnectionModeReader.ReadCallback(Object state)
System.ServiceModel.Channels.TracingConnection.TracingConnectionState.ExecuteCallback()
System.ServiceModel.Channels.TracingConnection.WaitCallback(Object state)
System.ServiceModel.Channels.SocketConnection.FinishRead()
System.ServiceModel.Channels.SocketConnection.AsyncReadCallback(Boolean haveResult, Int32 error, Int32 bytesRead)
System.ServiceModel.Channels.OverlappedContext.CompleteCallback(UInt32 error, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
System.Runtime.Fx.IOCompletionThunk.UnhandledExceptionFrame(UInt32 error, UInt32 bytesRead, NativeOverlapped* nativeOverlapped)
System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
        <netTcpBinding>
            <binding name="NetTcpEndPoint_ISolutionsDataAccessorV01" 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="524288" maxBufferSize="65536" maxConnections="10"
                maxReceivedMessageSize="65536">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <reliableSession ordered="true" inactivityTimeout="00:10:00"
                    enabled="false" />
                <security mode="Transport">
                    <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
                    <message clientCredentialType="Windows" />
                </security>
            </binding>
        </netTcpBinding>

    </bindings>
    <client>
        <endpoint address="net.tcp://localhost:1177/TcpService" binding="netTcpBinding"
            bindingConfiguration="NetTcpEndPoint_ISolutionsDataAccessorV01"
            contract="sDAL.ISolutionsDataAccessorV01" name="NetTcpEndPoint_ISolutionsDataAccessorV01">
            <identity>
                <userPrincipalName value="abc@xyz.com" />
            </identity>
        </endpoint>
    </client>
</system.serviceModel>
<behaviors>
  <serviceBehaviors>
    <behavior name="SolutionsDALServiceBehavior">
   <serviceCredentials>
     <serviceCertificate findValue="STSTestCert"
                         x509FindType="FindByIssuerName" />
   </serviceCredentials>
    <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
      <!-- <serviceMetadata httpGetEnabled="true"/> -->
      <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="true"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
客户:

        <netTcpBinding>
            <binding name="NetTcpEndPoint_ISolutionsDataAccessorV01" 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="524288" maxBufferSize="65536" maxConnections="10"
                maxReceivedMessageSize="65536">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <reliableSession ordered="true" inactivityTimeout="00:10:00"
                    enabled="false" />
                <security mode="Transport">
                    <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
                    <message clientCredentialType="Windows" />
                </security>
            </binding>
        </netTcpBinding>

    </bindings>
    <client>
        <endpoint address="net.tcp://localhost:1177/TcpService" binding="netTcpBinding"
            bindingConfiguration="NetTcpEndPoint_ISolutionsDataAccessorV01"
            contract="sDAL.ISolutionsDataAccessorV01" name="NetTcpEndPoint_ISolutionsDataAccessorV01">
            <identity>
                <userPrincipalName value="abc@xyz.com" />
            </identity>
        </endpoint>
    </client>
</system.serviceModel>
<behaviors>
  <serviceBehaviors>
    <behavior name="SolutionsDALServiceBehavior">
   <serviceCredentials>
     <serviceCertificate findValue="STSTestCert"
                         x509FindType="FindByIssuerName" />
   </serviceCredentials>
    <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
      <!-- <serviceMetadata httpGetEnabled="true"/> -->
      <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="true"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
服务: ->

        <netTcpBinding>
            <binding name="NetTcpEndPoint_ISolutionsDataAccessorV01" 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="524288" maxBufferSize="65536" maxConnections="10"
                maxReceivedMessageSize="65536">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <reliableSession ordered="true" inactivityTimeout="00:10:00"
                    enabled="false" />
                <security mode="Transport">
                    <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
                    <message clientCredentialType="Windows" />
                </security>
            </binding>
        </netTcpBinding>

    </bindings>
    <client>
        <endpoint address="net.tcp://localhost:1177/TcpService" binding="netTcpBinding"
            bindingConfiguration="NetTcpEndPoint_ISolutionsDataAccessorV01"
            contract="sDAL.ISolutionsDataAccessorV01" name="NetTcpEndPoint_ISolutionsDataAccessorV01">
            <identity>
                <userPrincipalName value="abc@xyz.com" />
            </identity>
        </endpoint>
    </client>
</system.serviceModel>
<behaviors>
  <serviceBehaviors>
    <behavior name="SolutionsDALServiceBehavior">
   <serviceCredentials>
     <serviceCertificate findValue="STSTestCert"
                         x509FindType="FindByIssuerName" />
   </serviceCredentials>
    <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
      <!-- <serviceMetadata httpGetEnabled="true"/> -->
      <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="true"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>