29

大きな文字列(24,000〜50,000文字)を自己ホスト型TCPWCFサービスに渡そうとしています。

maxStringContentLength(どこでも)を22008192にアップしました。

どこかで、bindingConfigurationを「LargeBuffer」または「LongFields」に変更する必要があることを読みましたが、これを行うと、次のようになります。

<endpoint address="" binding="netTcpBinding" bindingConfiguration="LongFields"
  contract="ExStreamWCF.IService1">

またはこれ:

<endpoint address="" binding="netTcpBinding" bindingConfiguration="LargeBuffer"
  contract="ExStreamWCF.IService1">

サービスが開始されません。私は本当にこのエラーをなくす必要があります。何か案は?

ありがとう、

ジェイソン

PS-サーバー上のtcpサービスからの構成ファイル:

<system.serviceModel>
<services>
  <service behaviorConfiguration="ExStreamWCF.Service1Behavior"
    name="ExStreamWCF.Service1">
    <endpoint address="" binding="netTcpBinding" bindingConfiguration=""
      contract="ExStreamWCF.IService1">
      <identity>
        <dns value="Devexstream-2.anchorgeneral.local" />
        <!--<dns value="vmwin2k3sta-tn2" />-->
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
      contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="net.tcp://Devexstream-2:8080/Service" />
        <!--<add baseAddress="net.tcp://vmwin2k3sta-tn2:8080/Service" />-->
      </baseAddresses>
    </host>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="ExStreamWCF.Service1Behavior">
      <serviceMetadata httpGetEnabled="false" />
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>

編集:要求に応じたバインディング

    <system.serviceModel>
    <bindings>
<netTcpBinding>
<binding name="NetTcpBinding_IService1" 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="2565536" maxConnections="10" maxReceivedMessageSize="2565536">
 <readerQuotas maxDepth="22008192" maxStringContentLength="22008192" maxArrayLength="2516384"
  maxBytesPerRead="22008192" maxNameTableCharCount="22008192" />
 <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://devexstream-2:8080/Service" binding="netTcpBinding"
bindingConfiguration="NetTcpBinding_IService1" contract="TCPService.IService1"
         name="NetTcpBinding_IService1">
<identity>
 <servicePrincipalName value="TCPService\Devexstream-2" />
 <dns value="Devexstream-2.anchorgeneral.local" />
</identity>
</endpoint>

サービスを編集しましたが(次のように)、サービスが開始されません。新しいapp.config:

<system.serviceModel>
<bindings>
  <netTcpBinding>
    <binding name="ExStreamWCFBinding" closeTimeout="00:00:05" openTimeout="00:00:05" receiveTimeout="00:00:05" sendTimeout="00:00:05" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparison="StrongWildCard" maxBufferPoolSize="524288" maxBufferSize="524288" maxConnections="10" maxReceivedMessageSize="5242880">
      <readerQuotas maxDepth="32" maxStringContentLength="5242880" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
    </binding>
  </netTcpBinding>
</bindings>
<services>
  <service behaviorConfiguration="ExStreamWCF.Service1Behavior"
    name="ExStreamWCF.Service1">
    <endpoint address="" binding="netTcpBinding" bindingConfiguration="ExStreamWCFBinding"
      contract="ExStreamWCF.IService1">
      <identity>
        <dns value="Devexstream-2.anchorgeneral.local" />
        <!--<dns value="vmwin2k3sta-tn2" />-->
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
      contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="net.tcp://Devexstream-2:8080/Service" />
        <!--<add baseAddress="net.tcp://vmwin2k3sta-tn2:8080/Service" />-->
      </baseAddresses>
    </host>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="ExStreamWCF.Service1Behavior">
      <serviceMetadata httpGetEnabled="false" />
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>

4

2 に答える 2

37

bindingConfiguration には、netTcpinding 要素に割り当てる名前が必要です。「LargeBuffer」または「LongFields」は、構成ファイルにその名前のバインディング要素がない限り、何の意味もありません。それを入れてもサービスが開始されないのはそのためです。おそらく、何らかの構成エラーメッセージが表示されるでしょう。

maxStringContentLength のデフォルトの 8192 設定をオーバーライドするには、次のようにします。

  1. maxStringContentLength に必要なサイズの Binding 要素を構成ファイルに作成し、name 属性で名前を付けます。
  2. endpoint 要素で、上記の手順 1 の名前を bindingConfiguration 属性に割り当てます。

エンドポイントのバインド構成を指定しない場合、サービスは既定値を使用します。

たとえば、上記の構成ファイルを取り上げます。タグの下に、次のバインド構成を追加します (使用する特定の値とオプションの属性は、サービスのニーズによって異なることに注意してください)。

<bindings>
  <netTcpBinding>
    <binding name="ExStreamWCFBinding" closeTimeout="00:00:05" openTimeout="00:00:05" receiveTimeout="00:00:05" sendTimeout="00:00:05" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparison="StrongWildCard" maxBufferPoolSize="524288" maxBufferSize="524288" maxConnections="10" maxReceivedMessageSize="5242880">
      <readerQuotas maxDepth="32" maxStringContentLength="5242880" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
    </binding>
  </netTcpBinding>
</bindings>

次に、エンドポイントを定義するとき:

<endpoint address="" binding="netTcpBinding" bindingConfiguration="ExStreamWCFBinding" contract="ExStreamWCF.IService1"> 

追加するために編集

追加情報に基づいて、サービスのエンドポイントで bindingConfiguration 属性に値「NetTcpBinding_IService1」を割り当てます。

于 2011-07-06T17:32:17.657 に答える