简体   繁体   中英

WCF Service Reference Can't be updated over HTTPS

I've had some WCF services (consumed by a WinForms app) running under IIS now for some time without issue. I was just going to revisit them and add some new features, and now I've got a problem that first became apparent when I tried to update the Service Reference in Visual Studio.

Right click on the existing Service Reference and then Update Service Reference in Visual Studio throws an error:

There was an error downloading ' https://www.test.com/WCF/MyService.svc '. The request failed with HTTP status 400: Bad Request. Metadata contains a reference that cannot be resolved: (etc...)

If I open up https://www.test.com/WCF/MyService.svc or https://www.test.com/WCF/MyService.svc?wsdl in my web browser, I also get a 400 Bad Request. HOWEVER , if I access either of those URLs via http (not https), then I get the service screen and the wsdl. I then tried using http when requesting the Service Update in VS, and it works, but this service is supposed to be using HTTPS only!

Here is my server side web.config :

<system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="false" 
            multipleSiteBindingsEnabled="false" 
            minFreeMemoryPercentageToActivateService="0"/>
    <bindings>
        <wsHttpBinding>
            <binding name="wsHttpBindingConfig" 
                 receiveTimeout="00:05:00" sendTimeout="00:01:00" 
                 maxReceivedMessageSize="5000000">
                <security mode="TransportWithMessageCredential">
                    <transport clientCredentialType="None"/>
                    <message clientCredentialType="UserName"/>
                </security>
            </binding>
        </wsHttpBinding>
    </bindings>
    <services>
        <service name="MyService"
                 behaviorConfiguration="ServiceBehavior" >
            <endpoint name="MyServiceEndpoint" 
                address="https://www.test.com/WCF/MyService.svc" 
                binding="wsHttpBinding" 
                bindingConfiguration="wsHttpBindingConfig" 
                contract="IMyService"/>
        </service>
    </services>
    <behaviors>
        <serviceBehaviors>
            <behavior name="ServiceBehavior">
                <serviceMetadata httpGetEnabled="true"/>
                <serviceDebug includeExceptionDetailInFaults="true"/>
                <serviceCredentials>
                    <userNameAuthentication 
                         userNamePasswordValidationMode="MembershipProvider" 
                         membershipProviderName="AspNetSqlMembershipProvider"/>
                </serviceCredentials>
                <serviceAuthorization 
                     principalPermissionMode="UseAspNetRoles" 
                     roleProviderName="AspNetSqlRoleProvider"/>
            </behavior>
            <behavior name="">
                <serviceMetadata httpGetEnabled="true"/>
                <serviceDebug includeExceptionDetailInFaults="false"/>
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <!-- enables WCF logging -->
    <diagnostics wmiProviderEnabled="false" performanceCounters="Off">
        <messageLogging logEntireMessage="true" 
              logMalformedMessages="true" logMessagesAtServiceLevel="true" 
              logMessagesAtTransportLevel="true" maxMessagesToLog="200" 
              maxSizeOfMessageToLog="50000"/>
    </diagnostics>
</system.serviceModel>

Some background info that might help(?):

  1. Just upgraded to Win10 and VS2015 on my dev machine. Trying to update Service Reference in VS2010 or VS2015 gives same result.

  2. Just realized that my web hosting company was NOT applying updates to the server like I'm paying them to do. Just did 4 years (!) worth of Windows Updates to my trusty old Win2008 server.

  3. Chrome complains that my server's certificate is valid but obsolete (uses SHA1), other browsers don't complain. I have an SHA2 certificate on the way, but don't see how this should make any difference.

Finally, the web service still works in its original capacity via HTTPS right now. But any attempt to update the reference via HTTPS fails with 400 Bad Request.

Two days of google/stackoverflow searches and I can't come up with anything. Anyone got a hint or clue or something to try?

I don't know what happened, but I could update references via HTTPS before, and now I can't. I guess I was concerned because I thought that would affect the "auto configuration" of the endpoint in my app.config. However, updating the service reference via HTTP seems to have no affect on my app.config settings (which accesses the service via HTTPS).

In other words, there isn't any problem. I just updated via HTTP, and the service can still be called by my WinForms app via HTTPS no problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM