2017-01-23 6 views
0

私はJsonオブジェクトで作業する必要があるWCFサービスを実装しています。これまでのところこれが働いています。今、私はサービスがhttpsだけを受け入れるようにしたいので、httpはありません。Jsonとhttpsを実装するWcfサービス

両方の要件について、私はテストして動作するように見えるサンプルをいくつか見つけました。しかし、両方の要件を1つの設定ファイルに統合することはできません。

これは、サービスのための私の設定です:

<?xml version="1.0"?> 
<configuration> 

    <appSettings> 
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" /> 
    </appSettings> 

    <system.web> 
    <compilation debug="true" targetFramework="4.5.2" /> 
    <httpRuntime targetFramework="4.5.2"/> 
    </system.web> 

    <system.serviceModel> 
    <services> 
     <service behaviorConfiguration="serviceBehavior" name="SMApi.SApi"> 
     <endpoint address="" behaviorConfiguration="web" binding="webHttpBinding" 
      bindingConfiguration="" contract="SMApi.ISApi" /> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <!--/--> 
     <behavior name="serviceBehavior"> 
      <serviceMetadata httpGetEnabled="true"/> 
      <serviceDebug includeExceptionDetailInFaults="true"/> 
     </behavior> 
     <!--/--> 
     <behavior> 
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/> 
     </behavior> 
     </serviceBehaviors> 
     <!--/--> 
     <endpointBehaviors> 
     <behavior name="web"> 
      <webHttp/> 
     </behavior> 
     </endpointBehaviors> 
     <!--/--> 
    </behaviors> 
    <protocolMapping> 
     <add binding="basicHttpsBinding" scheme="https"/> 
    </protocolMapping> 
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> 
    </system.serviceModel> 

    <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"/> 
    <directoryBrowse enabled="false"/> 
    </system.webServer> 

</configuration> 
+0

'webHttpBinding'に輸送するセキュリティモードを設定してみてください。あなたはそれのためのあなたの設定にバインディング設定セクションを追加する必要があります。 – Tim

答えて

0

てみ<webHttpBinding>のための結合構成を追加し、トランスポートにセキュリティモードを設定します。エンドポイントにバインド設定を明示的に設定する必要があります。あなたのエンドポイント参照で次に

<bindings> 
    <webHttpBinding name="SMApiWebhttpBinding"> 
    <security mode="Transport" /> 
    </webHttpBinding> 
</bindings> 

binding Configuration属性を経由して設定を結合上記:

<service behaviorConfiguration="serviceBehavior" 
     name="SMApi.SApi"> 
    <endpoint address="" behaviorConfiguration="web" 
      binding="webHttpBinding" 
      bindingConfiguration="SMApiWebHttpBinding" 
      contract="SMApi.ISApi" /> 
関連する問題