Aaron
Aaron

Reputation: 1323

WCF Rest Service - worked great ... Until SSL

I have a WCF Rest service that has been running very smoothly. I just got my SSL cert and installed it in IIS, added an auto redirect to https (basically, forcing https). Now, if I go to "website/ServiceDirectory/Service.svc, I still get the "You have created a service" message, but when I attempt to actually call the service, I'm getting 404 not found. I have already looked through numerous articles. I've disabled http/enabled https. I've ensured I enabled "Transport" security in the binding..Not sure if I'm just missing something or what's going on. Here's my web config, but I'm beginning to think it may be something in IIS

  <system.serviceModel>
<client>
  <endpoint address=""
            binding="webHttpBinding" bindingConfiguration="WebBinding"
            behaviorConfiguration="web"
            contract="EngageService.IEngage" name="win"/>
</client>
<bindings>
  <webHttpBinding>
    <binding name="WebBinding">
      <security mode="Transport">
        <transport clientCredentialType="None"/>
      </security>
    </binding>
  </webHttpBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
<services>
  <service behaviorConfiguration="ServiceBehavior" name="EngageService.Engage1">
    <endpoint address="" behaviorConfiguration="web" binding="webHttpBinding"
      contract="EngageService.IEngage" bindingConfiguration="WebBinding" />
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="ServiceBehavior">
      <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
  </serviceBehaviors>
  <endpointBehaviors>
    <behavior name="web">
      <webHttp defaultOutgoingResponseFormat="Xml"/>
    </behavior>
  </endpointBehaviors>
</behaviors>
<protocolMapping>
  <!--<add binding="basicHttpBinding" scheme="http"/>-->
  <add binding="basicHttpsBinding" scheme="https"/>
</protocolMapping>

In IIS, the service is configured as an application, and as I stated it was working perfectly before I switched to https. Does anyone either see something wrong with my config file, or know of any IIS configuration items I may need to check/change? Thanks

Upvotes: 1

Views: 2039

Answers (1)

Aaron
Aaron

Reputation: 1323

Ok so this boiled down to the protocolmapping section. It seems that without this mapping, webhttpbinding defaults to http. Added the webhttpbinding, including the entire section to make it easier to spot - hopefully this helps someone else one day.

<protocolMapping>
  <!--<add binding="basicHttpBinding" scheme="http"/>-->
  <add binding="basicHttpsBinding" scheme="https"/>
  <add binding="webHttpBinding" scheme="https" bindingConfiguration="WebBinding"/>
</protocolMapping>

If you have tried all of the other articles and still can't get it - try the above. It breaks http, but I imagine only because you're stealing the endpoint. If you configured a secondary http binding, I would bet it would work perfectly.

Upvotes: 1

Related Questions