1

myServiceにカスタムメッセージヘッダーを追加したいのですが、次のリンクをたどっています。

http://trycatch.me/adding-custom-message-headers-to-a-wcf-service-using-inspectors-behaviors/

私はそれを適切に構成し、サーバー側ではIServiceBehavior.ApplyDispatchBehaviorがデバッグを実行しており、ServiceDescription.Endpoints [0] .Behaviorsでカスタム動作を確認できますが、ServiceEndpointCollection endpoints = MetadataResolver.Resolve(descriptions、address、 MetadataExchangeClientMode.MetadataExchange、クライアント); ビヘイビアーコレクションは空であるため、IEndpointBehavior.ApplyDispatchBehavior関数とIEndpointBehavior.ApplyClientBehavior関数は呼び出されません-誰かがアイデアを持っていますか?これが私の設定ファイルです:

<configuration>
  <system.serviceModel>
    <services>
      <service behaviorConfiguration="DefaultBehavior" name="MyService">
        <endpoint address="DatabaseService" behaviorConfiguration="MyCustomBehavior"
          binding="customBinding" bindingConfiguration="DefaultBindingConfig"
          contract="IMyService" />
        <endpoint address="mex" binding="netTcpBinding"
          bindingConfiguration="MexBindingConfig" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://localhost/Services/SomeService" />
          </baseAddresses>
        </host>
      </service>      
    </services>    
    <bindings>
      <netTcpBinding>
        <binding name="MexBindingConfig" maxReceivedMessageSize="25000000" listenBacklog="30" maxConnections="30" portSharingEnabled="true">
          <readerQuotas maxArrayLength="25000000" maxStringContentLength="25000000" maxBytesPerRead="25000000" />
          <security mode="None">
          </security>
        </binding>
      </netTcpBinding>
      <customBinding>
        <binding name="DefaultBindingConfig" openTimeout="00:11:01" receiveTimeout="Infinite" sendTimeout="00:11:01" closeTimeout="00:11:01">
          <binaryMessageEncoding>
            <readerQuotas maxArrayLength="25000000" maxDepth="25000000" maxNameTableCharCount="25000000" maxStringContentLength="25000000" maxBytesPerRead="25000000" />
          </binaryMessageEncoding>
          <ImposedQuotas />
          <tcpTransport portSharingEnabled="true" maxBufferPoolSize="25000000" maxReceivedMessageSize="25000000" maxBufferSize="25000000">
          </tcpTransport>
        </binding>        
      </customBinding>
    </bindings>
    <behaviors>
      <endpointBehaviors>
        <behavior name="MyCustomBehavior">
          <MyCustomBehaviorExtension />
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="DefaultBehavior">
          <serviceMetadata />
          <serviceDebug includeExceptionDetailInFaults="true" />
          <serviceThrottling maxConcurrentCalls="1000" maxConcurrentSessions="1000" />
          <dataContractSerializer maxItemsInObjectGraph="2147483647" />
          <MyCustomBehaviorExtension />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <extensions>
      <behaviorExtensions>
        <add name="MyCustomBehaviorExtension" type="Namespace.MyCustomBehaviorExtension, MyDllName, Version=0.0.0.1, Culture=neutral, PublicKeyToken=null" />
      </behaviorExtensions>      
    </extensions>
    <diagnostics performanceCounters="Off" />
  </system.serviceModel>
</configuration>
4

0 に答える 0