0

カーストWCFファシリティを自分のサービスとうまく統合しました。次に、BasicHttpBindingに基づいてHTTPS通信を構成しようとします。

次のブログ投稿によると、これは大したことではないはずです:http: //blog.adnanmasood.com/2008/07/16/https-with-basichttpbinding-note-to-self/

これが私の設定です。クライアント側では、次のコードを使用してWindsorコンテナーを構成します。

    BasicHttpBinding clientBinding = new BasicHttpBinding();

    // These two lines are the only thing I changed here to allow HTTPS
    clientBinding.Security.Mode = BasicHttpSecurityMode.Transport;
    clientBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
    // Everything else worked well with HTTP

    clientBinding.MaxReceivedMessageSize = 163840;
    clientBinding.MaxBufferSize = (int)clientBinding.MaxReceivedMessageSize;

    container = new WindsorContainer();
    container.AddFacility<WcfFacility>();
    container.Register(
        Component.For<IClientService>()
        .AsWcfClient(new DefaultClientModel {
              Endpoint = WcfEndpoint.BoundTo(clientBinding)
              .At(configuration.Get(CFGKEY_SERVICE_CLIENT))
        })
     );

それ以外に、クライアント側の構成はありません。これは、HTTP通信を使用してうまく機能しました。

サーバー側は、Web.config内で次の構成を取得しました。

<system.serviceModel>
  <behaviors>
    <serviceBehaviors>
      <behavior name="">
        <serviceMetadata httpsGetEnabled="true" />
        <serviceDebug includeExceptionDetailInFaults="true" />
      </behavior>
    </serviceBehaviors>
  </behaviors>
  <serviceHostingEnvironment aspNetCompatibilityEnabled="true"
    multipleSiteBindingsEnabled="true" />

https://を介して接続しようとすると、次の例外が発生します。

System.ServiceModel.EndpointNotFoundException:メッセージを受け入れることができるhttps://myuri.com/Services/Client.svcでリッスンしているエンドポイントがありませんでした。

何が欠けているのかアイデアはありますか?前もって感謝します。

4

1 に答える 1

2

自分で修正しました。上記のコードは正しいです。問題はサーバー側のWindsorサービスインストーラー内にあります。各サービスポイントの次のスニペットがその役割を果たします。

ご覧のとおり、Web.configファイルのアプリ設定セクションに絶対サービスURIとトランスポートモード(httpまたはhttpsのいずれか)を配置しました。もちろん、デフォルトのWCF構成モデルを使用すると便利ですが、これは機能しませんでした。

        .Register(
            Component
            .For<MyNamespace.ContractInterface>()
            .ImplementedBy<MyNamespace.ImplementationClass>()
            .Named("ServiceName").LifestylePerWcfOperation()
            .AsWcfService(
                new DefaultServiceModel().Hosted().AddEndpoints(
                    WcfEndpoint.BoundTo(new BasicHttpBinding { 
                        Security = new BasicHttpSecurity { 
                            Mode = (WebConfigurationManager.AppSettings["Service.WCFFacility.TransportMode"] == "http") ? BasicHttpSecurityMode.None : BasicHttpSecurityMode.Transport, 
                            Transport = new HttpTransportSecurity { 
                                ClientCredentialType = HttpClientCredentialType.None 
                            } 
                        }
                    }).At(WebConfigurationManager.AppSettings["Service.WCFFacility.Endpoint"])
                )
            )
        );

サーバー構成は、アプリ設定キーを除いて、上記のとおりです。

これが同様の問題を経験している誰かを助けるかもしれないことを願っています。

于 2012-10-12T09:50:21.463 に答える