不支持协议“ https”

时间:2019-01-04 13:19:19

标签: wcf

我正在使用IIS中托管的WCF服务,但是当我尝试导航到端点时,收到错误消息“ 不支持协议'https'” 。它托管在本地运行Windows 10的IIS 10中。

该服务将wsHttpBinding与TransportWithMessageCredential一起使用。

此错误与SSL证书或IIS有关吗?

我的本​​地计算机>个人证书存储区中已经有一个有效的本地主机证书。

到目前为止我尝试过的事情

  1. 将httpsGetUrl属性设置为.svc端点。
  2. 已检查的IIS设置和默认协议设置为“ http”,这意味着 http和https协议均已启用。
  3. 检查应用程序池是否正在使用.NET Framework 4.0
  4. 重新启动应用程序池

我很高兴有人可以帮助我。

这是当前配置:

    <?xml version="1.0"?>
    <configuration>
    <system.web>
    <compilation debug="true" targetFramework="4.0" />
    </system.web>

    <system.serviceModel>
    <services>
        <service name="XXX.Zoo.WebServices.ZooServices_3_0" 
      behaviorConfiguration="ZooServices_3_0_Behavior">
            <endpoint
                address="https://localhost/Zootest_3_0/ZooServices_3_0.svc"
                binding="wsHttpBinding"
                bindingConfiguration="ZooServices_3_0_Binding"
                contract="XXX.Zoo.WebServices.IZooServices_3_0" />
            <endpoint

          address="https://localhost/Zootest_3_0/ZooServices_3_0.svc/mex"
                binding="mexHttpsBinding"
                contract="IMetadataExchange" />
        </service>
        </services>
       <bindings>
        <wsHttpBinding>
            <binding name="ZooServices_3_0_Binding"
                maxReceivedMessageSize="2147483647"
                maxBufferPoolSize="2147483647" >
                <readerQuotas
                    maxDepth="2147483647"
                    maxStringContentLength="2147483646"
                    maxArrayLength="2147483647"
                    maxBytesPerRead="2147483647"
                    maxNameTableCharCount="2147483647"/>
                <security mode="TransportWithMessageCredential">
                    <transport clientCredentialType="None" 
                     proxyCredentialType="None" realm="" />
                    <message clientCredentialType="Certificate" 
              negotiateServiceCredential="true" algorithmSuite="Default" 
              establishSecurityContext="true" />
                </security>
            </binding>
        </wsHttpBinding>
      </bindings>
        <behaviors>
        <serviceBehaviors>
            <behavior name="ZooServices_3_0_Behavior">
                <serviceMetadata httpsGetEnabled="true" 
           httpsGetUrl="https://localhost/Zootest_3_0/ZooServices_3_0.svc" />
                <serviceDebug includeExceptionDetailInFaults="False" />
                <!--The serviceCredentials behavior defines a service 
                  certificate which is used by the service to authenticate 
              itself to  its clients and to provide message protection. -->
                <serviceCredentials>
                    <serviceCertificate
                        findValue="localhost"
                        storeLocation="LocalMachine"
                        storeName="My"
                        x509FindType="FindBySubjectName" />
                    <clientCertificate>
                        <authentication 
                      certificateValidationMode="ChainTrust"/>
                    </clientCertificate>
                </serviceCredentials>
            </behavior>
                 </serviceBehaviors>
            </behaviors>        
          </system.serviceModel>
       </configuration>

2 个答案:

答案 0 :(得分:0)

此特殊错误已通过从配置中删除httpsGetUrl属性得到解决:

httpsGetUrl="https://localhost/Zootest_3_0/ZooServices_3_0.svc

所以最终结果如下:

<serviceMetadata httpsGetEnabled="true"/>

答案 1 :(得分:0)

如果要启用https协议支持,则应将使用传输传输模式的https端点添加到服务中。然后,我们应该在IIS网站绑定模块中设置https协议网站绑定。
enter image description here
我做了一个演示,希望对您有用。
服务器端。

   [ServiceContract]
    public interface IService1
    {
        [OperationContract]
        string GetData(int value);     
        }
    public class Service1 : IService1
    {

        public string GetData(int value)
        {
            return string.Format("You entered: {0}", value);
        }
    }

Web.config

<system.serviceModel>
    <services>
      <service name="WcfService1.Service1" behaviorConfiguration="mybehavior">
        <endpoint address="" binding="basicHttpBinding" contract="WcfService1.IService1" bindingConfiguration="https"></endpoint>
        <endpoint address="" binding="basicHttpBinding" contract="WcfService1.IService1" bindingConfiguration="http"></endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"></endpoint>
      </service>
    </services>
    <bindings>
      <basicHttpBinding>
        <binding name="https">
          <security mode="TransportWithMessageCredential">
            <transport clientCredentialType="None"></transport>
          </security>
        </binding>
        <binding name="http">
          <security mode="None">
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="mybehavior">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <protocolMapping>
        <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>    
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>

IIS。
enter image description here
这里有一些链接,希望对您有用。
WCF Service not hitting from postman over https
https://social.msdn.microsoft.com/Forums/vstudio/en-US/d42fc165-052d-476a-9580-1240b3d0293d/specify-endpoint-in-wcf-webconfig?forum=wcf
随时让我知道是否有什么可以帮助您的。