Configurando Https com WCF Rest

0

Recentemente encontrei um problema que era configurar um WCF que utilizava REST ao invés de SOAP utilizando HTTPS.

Segue a configuração que fiz no meu serviço:

<system.serviceModel>

    <services>
      <service behaviorConfiguration="SecureRESTSvcTestBehavior"  name="PH3A.Suburban.Site.PreAprovadosRest">


       <endpoint address=""
          binding="webHttpBinding"
          bindingConfiguration="webHttpTransportSecurity"
          behaviorConfiguration="webHttpBehavior"
          contract="PH3A.Suburban.Site.IPreAprovadosRest" />

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

      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="SecureRESTSvcTestBehavior">
          <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>

     
      <endpointBehaviors>
        <behavior name="webHttpBehavior">
          <webHttp/>
        </behavior>
      </endpointBehaviors>

    </behaviors>

    <bindings>
      <webHttpBinding>
        <binding name="webHttpTransportSecurity">
          <security mode="Transport" />
        </binding>
      </webHttpBinding>
    </bindings>

  </system.serviceModel>

No caso esta foi a configuração completa que precisei fazer para webHttpBinding funcionar corretamente.

Um grande abraço pessoal!

Compartilhe.