0

I am trying to convert a WCF service from http to https.

It is using a self-signed certificate.

I can browse to the service using web browser, but when I try to add it as a web reference in another .Net app, I get the following error:

There was an error downloading https://localhost:40300/DBService/SPService.svc/_vti_bin/ListData.svc/$metadata.
The request failed with HTTP status 403: Forbidden.

I have tried editing the web.config in various ways according to lots of Googling, but still have the above error with no way to narrow down the cause...

Here is my web.config:

<?xml version="1.0"?>
<configuration>
  <appSettings>
      <add key="DatabaseServer" value="Server2008"/>
      <add key="Database" value="Licensor"/>
      <add key="VerboseLogging" value="True"/>
    </appSettings>
  <system.web>
  <compilation targetFramework="4.0"/>
  <httpRuntime/>
  </system.web>
  <system.serviceModel>
    <services>
            <service name="DBService.SPService">
                <endpoint address="https://localhost/DBService/SPService.svc"
                        binding="basicHttpBinding"
                        bindingConfiguration="secureHttpBinding"
                        contract="DBService.IService1"/>

                <endpoint address="mex"
                        binding="mexHttpsBinding"
                        contract="IMetadataExchange" />
            </service>
    </services>
    <bindings>
      <basicHttpBinding>
        <binding name="secureHttpBinding">
          <security mode="Transport">
            <transport clientCredentialType="None"/>
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <!--<protocolMapping>
      <add binding="basicHttpsBinding" scheme="https"/>
    </protocolMapping>-->
    <serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true"/>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <directoryBrowse enabled="true"/>
  </system.webServer>
</configuration>

Can anyone help to find the cause, or even better point me towards a working sample of WCF over SSL using basicHttpBinding?

I have spent quite a few hours trying to resolve this so will appreciate your time on this one. If you need to I can provide access to my machine.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
james pearce
  • 355
  • 1
  • 5
  • 20
  • Don't you need to specify the certificate to use in your endpoint declaration? – Tim Aug 16 '14 at 22:00
  • how about just use https://localhost/DBService/SPService.svc for adding reference. – ZZZ Aug 16 '14 at 23:34
  • Possible duplicate of [BasicHttpBinding using transport sercurity with Self signed Certificate](http://stackoverflow.com/questions/5739780/basichttpbinding-using-transport-sercurity-with-self-signed-certificate) – jww Aug 17 '14 at 06:55
  • Sorry, I should have mentioned that it is hosted in IIS 8.5 on Windows 8. The certificate has been added to IIS and used in the website's binding. @Tim: would I still need to mention the certificate in this case? – james pearce Aug 17 '14 at 09:23
  • @Andy: I don't understand: do you mean use that address as a web reference? That's what I'm trying to do. – james pearce Aug 17 '14 at 09:24
  • @jww: There are lots of almost-duplicates of this: The one you are referring to has different symptoms and a different solution, but though there are lots with probably the same cause, I can't find one with the same error message that has a solution. – james pearce Aug 17 '14 at 09:24
  • https://localhost:40300/DBService/SPService.svc/_vti_bin/ListData.svc/$metadata is not a valid URL of retrieving WSDL from the Web service. https://localhost/DBService/SPService.svc?wsdl might be a good one. https://localhost means https://localhost:443, so which one you are using actually 443 or 40300? – ZZZ Aug 17 '14 at 10:22

0 Answers0