2011-08-12 9 views
7

protobuf-net(V1.0.0.280)ビヘイビア拡張で1つのエンドポイントが設定されている4つのエンドポイントを公開するWCFサービス(.NET 4)があります。しかし、protobuf-netの動作が開始されたのは、ALL protbuf-netを含む定義済みのエンドポイントが設定されていないことに気付きました!私は以下の設定を貼り付けました。何か不足していますか?すべてのヘルプは非常にTHX ..評価されて奇妙ですが、私は今まで内の変化にWCFによって私に供給されるエンドポイントをを適用する(コードをチェック)エンドポイントの動作設定Protobuf-netを使用したWCF

<service name="MyService" behaviorConfiguration="MyServiceBehavior"> 
    <endpoint address="Http.Basic" binding="basicHttpBinding" bindingConfiguration="Http.Basic.Config" contract="IMyService" behaviorConfiguration="DefaultBehavior" /> 
    <endpoint address="Http.Binary" binding="customBinding" bindingConfiguration="Http.Binary.Config" contract="IMyService" behaviorConfiguration="DefaultBehavior" /> 
    <endpoint address="Tcp.Binary" binding="customBinding" bindingConfiguration="Tcp.Binary.Config" contract="IMyService" behaviorConfiguration="DefaultBehavior" /> 
    <endpoint address="Http.ProtoBuf" binding="basicHttpBinding" bindingConfiguration="Http.Basic.Config" contract="IMyService" behaviorConfiguration="ProtoBufBehavior" /> 
    <host> 
     <baseAddresses> 
     <add baseAddress="http://localhost:8085/MyService"/> 
     <add baseAddress="net.tcp://localhost:8086/MyService"/> 
     </baseAddresses> 
    </host> 
    </service> 

    <behaviors> 
    <serviceBehaviors> 
     <behavior name="MyServiceBehavior"> 
     <serviceMetadata httpGetEnabled="true"/> 
     <serviceDebug includeExceptionDetailInFaults="true"/> 
     </behavior> 
    </serviceBehaviors> 
    <endpointBehaviors> 
     <behavior name="DefaultBehavior"> 
     <dataContractSerializer maxItemsInObjectGraph="2147483647" /> 
     </behavior> 
     <behavior name="ProtoBufBehavior"> 
     <ProtoBufSerialization /> 
     </behavior> 
    </endpointBehaviors> 
    </behaviors> 

    <bindings> 
    <basicHttpBinding> 
     <binding name="Http.Basic.Config" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" /> 
     <security mode="None"> 
     <transport clientCredentialType="None" proxyCredentialType="None" realm="" /> 
     <message clientCredentialType="UserName" algorithmSuite="Default" /> 
     </security> 
     </binding> 
    </basicHttpBinding> 
    <customBinding> 
     <binding name="Http.Binary.Config" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"> 
     <binaryMessageEncoding /> 
     <httpTransport allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" /> 
     </binding> 
     <binding name="Tcp.Binary.Config" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"> 
     <binaryMessageEncoding /> 
     <tcpTransport hostNameComparisonMode="StrongWildcard" /> 
     </binding> 
    </customBinding> 
    </bindings> 
+0

私たちはプログラム上で追加されたプロトの振る舞いと同じ問題を抱えています – Ruslan

答えて

1

void IEndpointBehavior.ApplyClientBehavior(ServiceEndpoint endpoint, System.ServiceModel.Dispatcher.ClientRuntime clientRuntime) 
    { 
     ReplaceDataContractSerializerOperationBehavior(endpoint); 
    } 

    void IEndpointBehavior.ApplyDispatchBehavior(ServiceEndpoint endpoint, System.ServiceModel.Dispatcher.EndpointDispatcher endpointDispatcher) 
    { 
     ReplaceDataContractSerializerOperationBehavior(endpoint); 
    } 

    private static void ReplaceDataContractSerializerOperationBehavior(ServiceEndpoint serviceEndpoint) 
    { 
     foreach (OperationDescription operationDescription in serviceEndpoint.Contract.Operations) 
     { 
      ReplaceDataContractSerializerOperationBehavior(operationDescription); 
     } 
    } 


    private static void ReplaceDataContractSerializerOperationBehavior(OperationDescription description) 
    { 
     DataContractSerializerOperationBehavior dcsOperationBehavior = description.Behaviors.Find<DataContractSerializerOperationBehavior>(); 
     if (dcsOperationBehavior != null) 
     { 
      description.Behaviors.Remove(dcsOperationBehavior); 
      description.Behaviors.Add(new ProtoOperationBehavior(description)); 
     } 
    } 

すなわち "エンドポイント(WCFによる)が与えられたら、オペレーション(メソッド)をそのエンドポイントでループし、シリアライザをDCSからPBに変更します。

これにより、契約d efinitions(したがって操作定義)自体はすべてのエンドポイント間で共有されますが、私は正直にそれについてはわかりません。そのの場合、エンドポイントごとに異なるプロセッサーを使用することは可能ではないことがわかります。しかし、私はWCF-guruではありません。これは...難解です。

+1

あなたの超高速応答のために多くの感謝と私はあなたのポイントを参照してください。私は、これを周りに遊んで本当に奇妙な何かに気づいた、つまり、私は、設定の最後のノードとしてprotobufの振る舞いを持つエンドポイントを保持しているすべての正常に動作します..しかし、私は最初の位置に移動し、 protobuf。私がそれを間に移動すると、それがprotobufを拾った後に定義されたエンドポイント!根本的な原因を見つけると深く掘り下げて投稿します – Japps

+0

私が理解しているように、contractDescriptionはエンドポイント間で共有されています。しかし、proto-behaviuor(動作が明示的に構成されているエンドポイントを含む)を持つエンドポイントの後に定義されたエンドポイントにのみproto-behaviourが追加される理由はわかりません。 @Jappsと同様のソリューションを使用します。ホストに最後のエンドポイントとしてprotoを付けたエンドポイントを追加します – Ruslan

関連する問題