WCF から HTTPS へのバインディング 質問する

WCF から HTTPS へのバインディング 質問する

これについては多くの投稿があることは承知しており、検索で見つかった投稿をすべて確認し、記載されているすべてのことを実装しました。ローカル システムで HTTP 経由で動作する WCF Web サービスがあり、サーバーでも HTTP 経由で動作しました。ただし、クライアントではこれが HTTPS 経由で動作する必要があります。このサイトや他のサイトの多数の投稿を見ると、これがそれほど簡単ではないことがわかります。これまで、ASMX Web サービスは「ただ動作」し、複雑な構成は必要ありませんでした。

現在の構成では次のエラーが発生します:

バインディング WSHttpBinding を持つエンドポイントのスキーム https に一致するベース アドレスが見つかりませんでした。登録されているベース アドレス スキームは [http] です。

これが、何日もかけてこれを動作するように設定しようとしたがうまくいかなかった現時点での私のコードです。

<system.serviceModel>

    <!--     -->
    <serviceHostingEnvironment  aspNetCompatibilityEnabled="true" >
        <baseAddressPrefixFilters>
            <add prefix="https://mysite.com"/>
            <add prefix="http://mysite.com"/>
        </baseAddressPrefixFilters>
    </serviceHostingEnvironment>

    <!-- Set up Custom Behaviors -->    
    <behaviors>

        <endpointBehaviors>
        </endpointBehaviors>

        <serviceBehaviors>
            <behavior name="WebPostService.WebPostServiceBehavior">
                <serviceMetadata httpsGetEnabled="true" httpsGetUrl="WebPostServices.svc/mex"  /> 
                <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
        </serviceBehaviors>

    </behaviors>

    <!-- Set up the binding configuration  -->
    <bindings>

        <wsHttpBinding>
            <binding    name="SOAPBinding" 
            >

                <security mode="Transport">
                </security>
            </binding>
        </wsHttpBinding>

    </bindings>

    <services>

        <service    
                    behaviorConfiguration="WebPostService.WebPostServiceBehavior"
                    name="WebPostService.WebPostService"
        >

    <host>
      <baseAddresses>
        <add baseAddress="https://mysite.com/Services/WebPostService.svc"/>
      </baseAddresses>
    </host>
            <endpoint   address="" 
                        binding="wsHttpBinding" 
                        bindingConfiguration="SOAPBinding"
                        contract="WebPostService.IWebPostService"
            >
                <identity>
                    <dns value="mysite.com" />
                </identity>
            </endpoint>

            <endpoint   
                        address="mex" 
                        binding="mexHttpsBinding" 
                        contract="IMetadataExchange" 
            >
            </endpoint>

        </service>

    </services>

</system.serviceModel>

何が間違っているのでしょうか。また、これを HTTPS 経由で動作させるにはどうすればよいのでしょうか。これが思ったほど簡単ではないことにイライラしています。このプロジェクトに取り組んでいる数か月間、MSDN の WCF ドキュメントに埋もれており、サービス、エンドポイント、バインディングについてはよく理解していますが、まったく知識がない場合よりもイライラするほどです。

更新: まだ作業中ですが、MEX アドレスの完全な URL を入力しようとしたときに奇妙なエラーが発生しました。次のように変更しました:

address="https://prcwebs.com/Services/WebPostService.svc/mex" 

エラーが発生しました:

このサービスのセキュリティ設定には Windows 認証が必要ですが、このサービスをホストする IIS アプリケーションでは Windows 認証が有効になっていません。

Windows認証を使用しようとしていません。セキュリティ設定は変更されておらず、まだ設定されています。

<セキュリティ モード="トランスポート" />

WebHttpBinding バインディングを持つエンドポイントのスキーム https に一致するベース アドレスが見つかりませんでした。登録されているベース アドレス スキームは [http] です。- 役に立たなかった、役に立つようなことは何も書かれていなかったバインディング WSHttpBinding を持つエンドポイントのスキーム http に一致するベース アドレスが見つかりませんでした- トランスポート セキュリティを使用していますが、これは当てはまりません。別のセキュリティ モードに変更してみましたが、それでもサイトを動作させることができませんでした。

ベストアンサー1

multipleSiteBindingsEnabled="true"を追加しserviceHostingEnvironment、セキュリティを更新してクライアント資格情報を無効にします。

<security mode="Transport">
    <transport clientCredentialType="None"></transport>
</security>

編集Windows 2003 での私の最終的な動作バージョンは次の構成でした。

<system.serviceModel>
    <serviceHostingEnvironment  aspNetCompatibilityEnabled="false" />

    <!-- Set up Custom Behaviors -->    
    <behaviors>
        <endpointBehaviors>
        </endpointBehaviors>
        <serviceBehaviors>
            <behavior name="WebPostService.WebPostServiceBehavior">
                <serviceMetadata httpsGetEnabled="true" httpsGetUrl="WebPostServices.svc/mex"  /> 
                <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
        </serviceBehaviors>
    </behaviors>

    <!-- Set up the binding configuration  -->
    <bindings>
        <wsHttpBinding>
            <binding name="SOAPBinding">
                <security mode="Transport">
                  <transport clientCredentialType="None"/>
                </security>
            </binding>
        </wsHttpBinding>
    </bindings>

    <services>
        <service behaviorConfiguration="WebPostService.WebPostServiceBehavior"
                 name="WcfService2.Service1">

            <host>
                <baseAddresses>
                    <add baseAddress="https://localhost/Service/Service1.svc"/>
                </baseAddresses>
            </host>
            <endpoint address="" 
                      binding="wsHttpBinding" 
                      bindingConfiguration="SOAPBinding"
                      contract="WcfService2.IService1">
                <identity>
                    <dns value="localhost" />
                </identity>
            </endpoint>

            <endpoint address="mex" 
                      binding="mexHttpsBinding" 
                      contract="IMetadataExchange">
            </endpoint>
        </service>
    </services>
</system.serviceModel>

https で Web サイトにアクセスできるため、インストールの証明書部分は正しいと思われます。私の設定と比較したい点があれば、お知らせください。

おすすめ記事