简体   繁体   English

WCF服务参考不能通过HTTPS更新

[英]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. 我已经在IIS下运行了一些WCF服务(由WinForms应用程序消耗)了一段时间,没有出现问题。 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. 我只是要重新访问它们并添加一些新功能,现在遇到了一个问题,当我尝试在Visual Studio中更新服务参考时,该问题首先变得显而易见。

Right click on the existing Service Reference and then Update Service Reference in Visual Studio throws an error: 右键单击现有的服务引用,然后在Visual Studio中更新服务引用会引发错误:

There was an error downloading ' https://www.test.com/WCF/MyService.svc '. 下载“ https://www.test.com/WCF/MyService.svc ”时出错。 The request failed with HTTP status 400: Bad Request. 请求失败,HTTP状态为400:错误的请求。 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. 如果在网络浏览器中打开https://www.test.com/WCF/MyService.svchttps://www.test.com/WCF/MyService.svc?wsdl ,我也会收到400错误的请求。 HOWEVER , if I access either of those URLs via http (not https), then I get the service screen and the wsdl. 但是 ,如果我通过http(不是https)访问这些URL中的任何一个,则将获得服务屏幕和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! 然后,我在VS中请求服务更新时尝试使用http,它可以工作,但是该服务应该仅使用HTTPS!

Here is my server side web.config : 这是我的服务器端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. 在我的开发机上刚刚升级到Win10和VS2015。 Trying to update Service Reference in VS2010 or VS2015 gives same result. 尝试在VS2010或VS2015中更新Service Reference会得到相同的结果。

  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. 我值得信赖的旧Win2008服务器仅进行了4年(!)的Windows更新。

  3. Chrome complains that my server's certificate is valid but obsolete (uses SHA1), other browsers don't complain. Chrome抱怨我的服务器证书有效,但是已经过时(使用SHA1),其他浏览器没有抱怨。 I have an SHA2 certificate on the way, but don't see how this should make any difference. 我正在获得SHA2证书,但是看不出这有什么区别。

Finally, the web service still works in its original capacity via HTTPS right now. 最终,Web服务现在仍可以通过HTTPS保持其原始功能。 But any attempt to update the reference via HTTPS fails with 400 Bad Request. 但是,任何通过HTTPS更新引用的尝试都将失败,并显示400错误请求。

Two days of google/stackoverflow searches and I can't come up with anything. 两天的google / stackoverflow搜索,我什么都没想。 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. 我不知道发生了什么,但是我以前可以通过HTTPS更新引用,但现在不能。 I guess I was concerned because I thought that would affect the "auto configuration" of the endpoint in my app.config. 我想我很担心,因为我认为这会影响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). 但是,通过HTTP更新服务引用似乎对我的app.config设置(通过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. 我只是通过HTTP更新的,该服务仍可以由WinForms应用通过HTTPS调用,没有问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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