1

I've been banging my head for a week now, I am trying to run a WCF service on IIS express and do a GET from the browser, everything works fine in HTTP, but the minute I try the HTTPS it fails with

HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

I have tried every single config file in stackoverflow answers I also tried this I know it is for IIS but I can't see why it is not working On IIS express. here my config file:

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


  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5"/>
  </system.web>


  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
    <behaviors>
      <endpointBehaviors>

        <behavior name="webHttpEnablingBehaviour">

          <webHttp />
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>

        <behavior name="webHttpEnablingBehaviour">
          <serviceMetadata httpGetEnabled="true" />
        </behavior>

      </serviceBehaviors>
    </behaviors>
    <services>
      <service
        name="ElasticSearchAPI.GetElasticService" behaviorConfiguration="webHttpEnablingBehaviour">
        <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />

        <endpoint address=""
          binding="webHttpBinding"
          bindingConfiguration="default"
          contract="ElasticSearchAPI.IGetElasticService"
          behaviorConfiguration="webHttpEnablingBehaviour">
        </endpoint>
        <endpoint address="other"
          binding="basicHttpBinding"
          bindingConfiguration="default"
          contract="ElasticSearchAPI.IGetElasticService">
        </endpoint>
      </service>

    </services>
    <client />
    <bindings>
      <webHttpBinding>
        <binding name="default" ></binding>
      </webHttpBinding>
      <basicHttpBinding>
        <binding name="default" allowCookies="true"></binding>
      </basicHttpBinding>
    </bindings>
  </system.serviceModel>

  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <validation validateIntegratedModeConfiguration="false"/>
    <!--
        To browse web app root directory during debugging, set the value below to true.
        Set to false before deployment to avoid disclosing web app folder information.
      -->
    <directoryBrowse enabled="true"/>

    <httpProtocol>
      <customHeaders>
        <add name="Access-Control-Allow-Origin" value="*" />
      </customHeaders>
    </httpProtocol>

  </system.webServer>

</configuration>

I am sure I am missing something really silly, but I am really out of ideas, your help is much appreciated.

Update

I can get to my .svc with https but when i try a get from a browser or post from fiddler nothing is working

dori naji
  • 980
  • 1
  • 16
  • 41
  • If anyone landed on this page searching for the answer, if your issue was webconfig this http://stackoverflow.com/questions/26558326/wcf-service-not-working-when-accessed-over-https-and-http will solve your issue. – dori naji Mar 06 '15 at 12:34

2 Answers2

0

Use ServiceBehaviour like below-

<serviceBehaviors>
    <behavior>
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
</behavior>

This may help you.

Rajat_RJT
  • 64
  • 7
0

In WCF Service Config file add following :

<binding name="secureHttpBinding">
 <security mode="Transport">
  <transport clientCredentialType="None" />
 </security>
</binding>

In client application config file add following :

<httpProtocol>
 <customHeaders>
        <add name="Access-Control-Allow-Origin" value="*" />
 </customHeaders>
</httpProtocol>

This will allow you to host and access WCF service with HTTPS protocol.

  • Thank you, but the question is already solved as I mentioned in my comment. and FYI the `Access-Control-Allow-Origin` is used so you can over come the CORS not for https protocol, it is for cross domain. – dori naji Mar 19 '15 at 09:21
  • Thanks for the information. In case service is hosted on HTTPS and client is requesting from HTTP (that you are requesting from the HTTP ) specifically in SOA for multiple clients then you need to use Access-Control-Allow-Origin. that's why i mentioned to add in client config file to prevent further error. – Aarifmohammad Mansuri Mar 19 '15 at 09:40