2

I've been looking around for a fix for this for some time now. I have been adding, which seems enlessly, to my web.config file all suggestions I've seen in order to fix this not working over SSL and working over basic http.

This is my current web.config:

<?xml version="1.0"?>
<configuration>
  <appSettings/>
  <system.web>
    <compilation debug="true" targetFramework="4.0"/>
    <httpRuntime/>
    <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
  </system.web>
  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true"/>
    <bindings>
      <customBinding>
        <binding name="basicConfig">
          <binaryMessageEncoding/>
          <httpTransport transferMode="Streamed" maxReceivedMessageSize="67108864" />
        </binding>
      </customBinding>
      <webHttpBinding>
        <binding name="Binding" crossDomainScriptAccessEnabled="true">
          <security mode="Transport">
            <transport clientCredentialType="None"/>
          </security>
        </binding>
        <binding name="httpbind" crossDomainScriptAccessEnabled="true"/>
      </webHttpBinding>
    </bindings>
    <client/>
    <services>
        <service name="Wcf.App.Service1" behaviorConfiguration="ServiceBehaviour">
          <endpoint address="customBinding" binding="customBinding" bindingConfiguration="basicConfig" contract="Wcf.App.IService1"/>
          <endpoint address="" binding="webHttpBinding" behaviorConfiguration="REST" contract="Wcf.App.IService1"/>
        </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehaviour">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
        <behavior name="REST">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="REST">
          <webHttp helpEnabled="true" defaultOutgoingResponseFormat="Json"/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <!--
        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"/>
  </system.webServer>
</configuration>

Most wsources say to do either 1 or the other (sometimes both) of the below:

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

and/or

 <serviceBehaviors>
    <behavior name="ServiceBehaviour">
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="true"/>
    </behavior>
    <behavior name="REST">
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
  </serviceBehaviors>

Which I currently have both in my web.config file.

As stated above, it works just fine when using HTTP: enter image description here

But when using HTTPS: enter image description here

I've also made sure that the IIS 8 that I am using to host the WCF RESTful web service was configured correctly. Again, I searched a lot and made sure that whatever was suggested I did. I currently have a legit PositiveSSL certificate from Comodo. enter image description here enter image description here So any help with this issue to get resolved would be great!

UPDATE FIDDLE

#   Result  Protocol    Host            URL                                 Body    Caching Content-Type                Process    Comments    Custom   
1   200     HTTP        Tunnel to       s--------a.info:443                 0                                           chrome:1796     
2   404     HTTPS       s--------a.info /Service1.svc/GetData/5556932587    3,353   private text/html; charset=utf-8    chrome:1796     

And this is what it looks like in fiddler for HTTP:

#   Result  Protocol    Host            URL                                 Body    Caching Content-Type                Process    Comments    Custom   
1   200     HTTP        s--------a.info /Service1.svc/GetData/5556932587    620     application/json; charset=utf-8     chrome:1796

However, just going to Service1.svc in HTTPS loads up just fine:

#   Result  Protocol    Host            URL             Body        Caching Content-Type        Process     Comments    Custom  
1   200     HTTPS       s--------a.info /Service1.svc   2,939       text/html; charset=UTF-8    chrome:1796 

Update again Well it looks like I finally got the web.config file correct to enable the SSL version to work but now that breaks the original HTTP.....

<?xml version="1.0"?>
<configuration>
  <appSettings/>
  <system.web>
    <compilation debug="true" targetFramework="4.0"/>
    <httpRuntime/>
    <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
  </system.web>
  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true"/>
    <bindings>
      <customBinding>
        <binding name="basicConfig">
          <binaryMessageEncoding/>
          <httpTransport transferMode="Streamed" maxReceivedMessageSize="67108864" />
        </binding>
      </customBinding>      
      <webHttpBinding>
        <binding name="basicConfig">
          <security mode="None">
            <transport clientCredentialType="Basic"/>
          </security>
        </binding>
        <binding>
          <security mode="Transport">
            <transport clientCredentialType="None"/>
          </security>
        </binding>
      </webHttpBinding>
    </bindings>
    <client/>
    <services>
        <service name="Wcf.App.Service1" behaviorConfiguration="ServiceBehaviour">
          <endpoint address="customBinding" binding="customBinding" bindingConfiguration="basicConfig" contract="Wcf.App.IService1"/>
          <endpoint address="" binding="webHttpBinding" behaviorConfiguration="REST" contract="Wcf.App.IService1"/>
        </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehaviour">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
        <behavior name="REST">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="ServiceBehaviour">
          <webHttp helpEnabled="true" defaultOutgoingResponseFormat="Json"/>
        </behavior>
        <behavior name="REST">
          <webHttp helpEnabled="true" defaultOutgoingResponseFormat="Json"/>
        </behavior>
      </endpointBehaviors>      
    </behaviors>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <!--
        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"/>
  </system.webServer>
</configuration>

Anyone have suggestions on how to make both work at the same time?

StealthRT
  • 10,108
  • 40
  • 183
  • 342
  • Wow - 99.99% of the time it's the *OPPOSITE* problem: works in HTTPS, fails in HTTP. SUGGESTION: compare the HTTPS vs HTTP cases (payload, header and HTTP query/response) in Firefox/Firebug, Chrome/Developer Tools ... or Fiddler: http://www.telerik.com/download/fiddler. GUESS: it sounds like the problem is in your HTTP query (it's requesting the wrong URL). Fiddler (or the other tools) will tell you for sure. – paulsm4 Jan 01 '16 at 23:53
  • I have Fiddler installed but it doesn't seem to tell me much other than what i just updated in my OP. – StealthRT Jan 02 '16 at 01:00
  • I would enable service tracing. – jsanalytics Jan 02 '16 at 05:01
  • @jstreet I'd be more than happy to do that if I new how. – StealthRT Jan 02 '16 at 05:02
  • Take a look: https://msdn.microsoft.com/en-us/library/ms733025%28v=vs.110%29.aspx – jsanalytics Jan 02 '16 at 05:05
  • @jstreet Oh, that. Yeah I tried that but it would never write a log file to anywhere I pointed it to write it. – StealthRT Jan 02 '16 at 05:07
  • It is not a big deal, i have done it multiple times. All you need is to have that `` section inserted into your service config file. – jsanalytics Jan 02 '16 at 05:09
  • Possible duplicate of [How to configure a single WCF Service to have multiple HTTP and HTTPS endpoints?](http://stackoverflow.com/questions/3824419/how-to-configure-a-single-wcf-service-to-have-multiple-http-and-https-endpoints). Fiddler indicates the client looks OK. Maybe the service simply isn't defined on HTTPS. Look at this link (or Google for "wcf service enable both http and https") and make sure endpoints (services, serviceBehaviors and bindings) are configured for *BOTH* HTTP and HTTPS. – paulsm4 Jan 02 '16 at 05:39
  • @paulsm4 Looks like I now have that issue with HTTPS working but not HTTP now.. Please see my updated OP. – StealthRT Jan 02 '16 at 17:37
  • Please read this link: [How to configure a single WCF Service to have multiple HTTP and HTTPS endpoints?](http://stackoverflow.com/questions/3824419/). You need to copy certain entries in your web.config *TWICE*. For example, you need a "webHttpBinding" *AND* you also need a "webHttpsBinding". Read the link carefully - it should have everything you need. – paulsm4 Jan 02 '16 at 19:16

0 Answers0