0

CreateBindingElemens メソッドにさまざまなバインディングを追加する、customizedBinding があります。HttpTransportBindingElement があればすべてうまく機能しますが、次のステップとしてトランスポート セキュリティ (ssl) を追加したいので、次のようにコードを変更しました。

        BindingElementCollection collection = new BindingElementCollection();
        collection.Add(httpPollingElement);
        if (session == SessionType.HttpSession)
        {
            collection.Add(httpSessionElement);
        }
        else
        {
            collection.Add(reliableSessionElement);
        }

        collection.Add(encodingElement);


        var securityBindingElement = new TransportSecurityBindingElement();
        collection.Add(securityBindingElement);
        collection.Add(httpTransportElement);
        return collection;

しかし、バインド 'System.ServiceModel.Channels.CustomBinding' のセキュリティ機能が、生成されたランタイム オブジェクトのセキュリティ機能と一致しないというエラーが表示されます。これはおそらく、バインディングに StreamSecurityBindingElement が含まれているが、ストリーム セキュリティ (TCP や名前付きパイプなど) をサポートする TransportBindingElement がないことを意味します。未使用の StreamSecurityBindingElement を削除するか、この要素をサポートするトランスポートを使用してください。

構成に StramSecurityBindingElement がないことを確認できます。これを機能させるには、どのセキュリティ バインディングを追加する必要がありますか?

4

1 に答える 1

1

ssl を使用するには、次を追加します。

new HttpsTransportBindingElement()

http要素の代わりに。トランスポート セキュリティのみを使用する場合は、セキュリティ要素を追加する必要はありません。

于 2012-06-21T13:00:02.400 に答える