WCF over SSL - 404 error

后端 未结 10 2264
执笔经年
执笔经年 2020-12-13 12:58

Okay, I must be missing something utterly simple here, because I\'ve been googling for days, and looking at dozens of answers there, and here on SO, and i just CANNOT get th

相关标签:
10条回答
  • 2020-12-13 13:17

    It didn't work for you before because you named your basicHttpBinding configuration basicHttpBinding but did not reference that configuration in your <service> tag with the bindingConfiguration="basicHttpBinding"

    In your changes that did work by adding another service configuration you then did reference the binding configuration that contains the <security> node hence causing it work.

    0 讨论(0)
  • 2020-12-13 13:21

    In my case non of these answers helped.

    Instead, I needed to add a duplicate <binding> section that has no name attribute set.

    Here is the dump of the appropriate section of my service's web.config file:

    <behaviors>
        <serviceBehaviors>
            <behavior name="ServiceBehaviour">
                <serviceMetadata 
                    httpsGetEnabled="true" 
                    httpsGetUrl="RemoteSyncService.svc"
                    httpGetBindingConfiguration="bindingConfig" />
                <serviceDebug includeExceptionDetailInFaults="true" />
            </behavior>
            <behavior name="">
                <serviceMetadata 
                    httpsGetEnabled="true" 
                    httpsGetUrl="RemoteSyncService.svc" />
                <serviceDebug includeExceptionDetailInFaults="true" />
            </behavior>
        </serviceBehaviors>
    </behaviors>
    
    <bindings>
      <basicHttpBinding>
        <binding name="bindingConfig" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" transferMode="Streamed">
            <security mode="Transport">
              <transport clientCredentialType="None"/>
            </security>
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
        </binding>
    
        <!-- Add binding with EMPTY/MISSING name, see https://forums.iis.net/t/1178173.aspx -->
        <binding maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" transferMode="Streamed">
            <security mode="Transport">
              <transport clientCredentialType="None"/>
            </security>
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
        </binding>
      </basicHttpBinding>
    </bindings>
    

    I do hope this might be helpful for someone, some day.

    0 讨论(0)
  • 2020-12-13 13:23

    I just spent a few hours on this and it turned out my problem was the service name

    <services>
          <service name="TimberMill.Web.Data.LogReceiverService">
            <endpoint binding="basicHttpBinding" bindingConfiguration="basicBinding"
                         contract="NLog.LogReceiverService.ILogReceiverServer" />
          </service>
        </services>
    

    had to exactly match the similar entry in my *.svc file.

    <%@ ServiceHost 
        Language="C#" 
        Debug="true" 
        Service="TimberMill.Web.Data.LogReceiverService, TimberMill.Web"
        Factory="Autofac.Integration.Wcf.AutofacServiceHostFactory, Autofac.Integration.Wcf"
        CodeBehind="LogReceiverService.svc.cs" 
    %>
    

    I'm not sure if it was related to my use of Autofac. It all was working fine under plain HTTP. Failed under HTTPS though.

    Well I think so, I don't want to disturb anything now by testing in more detail lest I anger the WCF-Config gods and my config breaks again. YMMV.

    0 讨论(0)
  • 2020-12-13 13:23

    Everything seems to be quite valid, no glaring mistakes at all...

    Just one observation/question: where is your *.svc file located??

    In the error message, I see:

     https://www.mydomain.com/myservice.svc 
    

    Is your *.svc file really in the top-level virtual directory of your site?

    Typically, the *.svc file is inside a virtual directory on IIS and thus the address would be something like:

     https://www.mydomain.com/YourVirtualDirectory/myservice.svc 
    

    Of course, you can deploy an ASP.NET app and a WCF service *.svc file to the root of your IIS - but it's not very common, in my experience.

    Just a thingie to check.....

    Marc

    0 讨论(0)
  • 2020-12-13 13:24

    Okay, I apparently fixed the issue, and I have absolutely no idea why/how.

    Here's what I did.

    • I added a BRAND NEW EMPTY Silverlight-enabled WCF service
    • I then updated the web.config to reflect both services
    • I then literally just copied and pasted everything about the first service into the second service, except the name.

    Why this fixed it, I have absolutely NO idea.

    FWIW for anyone, here is my new web.config ServiceModel section with the second service in it...

    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="basicHttpBinding">
                </binding>
                <binding name="basicHttpsBinding">
                    <security mode="Transport">
                        <transport clientCredentialType ="None"/>
                    </security>
                </binding>
            </basicHttpBinding>
        </bindings>
        <behaviors>
            <serviceBehaviors>
                <behavior name="standingsBehavior">
                    <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
                    <serviceDebug includeExceptionDetailInFaults="false"/>
                </behavior>
            </serviceBehaviors>
        </behaviors>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true">
            <baseAddressPrefixFilters>
                <add prefix="http://www.mydomain.com/"/>
            </baseAddressPrefixFilters>
        </serviceHostingEnvironment>
        <services>
            <service behaviorConfiguration="standingsBehavior" name="lijslwebdata">
                <endpoint address="" binding="basicHttpBinding" contract="lijslwebdata"/>
                <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
            </service>
            <service behaviorConfiguration="standingsBehavior" name="sslwebdata">
                <endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHttpsBinding" contract="sslwebdata"/>
                <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
            </service>
        </services>
    </system.serviceModel>
    
    0 讨论(0)
  • 2020-12-13 13:26

    I had this same issue on my end. Your post helped me figure out what the issue was. here is my service model section. I discovered that the keys were the httpsGetEnabled then setting the bindingconfiguration I hope this helps.

    <system.serviceModel>
            <behaviors>
                <serviceBehaviors>
                    <behavior name="RequestImageBehavior">
                        <serviceMetadata **httpsGetEnabled**="true" />
                        <serviceDebug includeExceptionDetailInFaults="false" />
                      <dataContractSerializer maxItemsInObjectGraph="1073741824" />
                    </behavior>
                </serviceBehaviors>
            </behaviors>
            <services>
                <service behaviorConfiguration="RequestImageBehavior" name="RequestImage">
                    <endpoint address="" 
                              binding="wsHttpBinding" 
                              **bindingConfiguration**="HttpsBinding"
                              contract="IRequestImage">
                    </endpoint>
                    <endpoint address="mex" 
                              binding="mexHttpBinding" 
                              contract="IMetadataExchange" />
                </service>
            </services>
          <bindings>
            **<wsHttpBinding>
              <binding name="HttpsBinding">
                <security mode="Transport">
                  <transport clientCredentialType="None"/>
                </security>
              </binding>
            </wsHttpBinding>**
          </bindings>
        </system.serviceModel>
    
    0 讨论(0)
提交回复
热议问题