WCF service not working when accessed over HTTPS and HTTP

后端 未结 2 595
感情败类
感情败类 2020-12-18 21:36

I\'ve installed a SSL certificate in IIS.

Now when I navigate to my domain https://www.example.com/ the page loads correctlty. But when I try to approach a web servi

相关标签:
2条回答
  • 2020-12-18 21:46

    These kind of web services can be super sensitive to whether you're using HTTP or HTTPS to access them.

    Try using this to enable SSL for WCF services in the web.config:

    <system.serviceModel>
        <bindings>
            <webHttpBinding>
                <binding>
                    <security mode="Transport" />
    

    I just had a similar problem, see my answer to this question for more info: Moved my ASP.NET website to IIS 8 on windows server 2012... services missing: .svc files are viewable, but their methods give a 404

    0 讨论(0)
  • 2020-12-18 22:10

    @Flo, Finally I am able to make it work. I have updated <endpoint behaviorConfiguration .. and set <service behaviorConfiguration=.., and it worked, i mean when you hit both http and https version of www.example.com/service.svc/newprofile/?id=8&ipaddress=124.162.13.109, it will get you correct output. Following is the system.serviceModel part of web.config. Please try this, let me know, if you are still not able to make it work.

    <system.serviceModel>
      <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
      <bindings>
        <webHttpBinding>
          <binding name="Binding" crossDomainScriptAccessEnabled="true">
            <security mode="Transport">
              <transport clientCredentialType="None" />
            </security>
          </binding>
          <binding name="httpbind" crossDomainScriptAccessEnabled="true">
          </binding>
        </webHttpBinding>
      </bindings>
      <client />
      <services>
        <service name="RestService.service"  behaviorConfiguration="ServiceBehaviour">
          <endpoint address="" binding="webHttpBinding" bindingConfiguration="Binding" contract="RestService.Iservice" behaviorConfiguration="web">
          </endpoint>
          <endpoint address="" binding="webHttpBinding" bindingConfiguration="httpbind" contract="RestService.Iservice" behaviorConfiguration="web">
          </endpoint>
        </service>
      </services>
      <behaviors>
        <serviceBehaviors>
          <behavior name="ServiceBehaviour">
            <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
            <serviceDebug includeExceptionDetailInFaults="true" />
          </behavior>
          <behavior name="web">
            <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
            <serviceDebug includeExceptionDetailInFaults="true" />
          </behavior>
        </serviceBehaviors>
        <endpointBehaviors>
          <behavior name="web">
            <webHttp helpEnabled="true" />
          </behavior>
        </endpointBehaviors>
      </behaviors>
    </system.serviceModel>
    
    0 讨论(0)
提交回复
热议问题