首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >不支持协议'https‘

不支持协议'https‘
EN

Stack Overflow用户
提问于 2019-01-04 13:19:18
回答 2查看 4K关注 0票数 1

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

该服务将wsHttpBinding与TransportWithMessageCredential结合使用。

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

我已经在本地机器>个人证书存储中拥有一个有效的本地主机证书。

我到目前为止尝试过的

  1. 将httpsGetUrl属性设置为.svc端点。
  2. 选中的IIS设置和默认协议被设置为" http“,这意味着启用了http和https协议。
  3. 检查应用程序池是否使用.NET Framework4.0
  4. 重新启动应用程序池

如果有人能帮我我很感激。

下面是当前的配置:

代码语言:javascript
复制
    <?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>
EN

回答 2

Stack Overflow用户

发布于 2019-01-07 10:49:46

通过从配置中删除httpsGetUrl属性解决了此特定错误:

代码语言:javascript
复制
httpsGetUrl="https://localhost/Zootest_3_0/ZooServices_3_0.svc

最终结果如下:

代码语言:javascript
复制
<serviceMetadata httpsGetEnabled="true"/>
票数 0
EN

Stack Overflow用户

发布于 2019-01-08 10:11:27

如果要启用https协议支持,则应该向服务中添加使用传输传输模式的https端点。然后,我们应该在IIS站点绑定模块中设置https协议站点绑定。

我做了一个演示,希望它对你有用。

服务器端.

代码语言:javascript
复制
   [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

代码语言:javascript
复制
<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。

这里有一些链接,希望它对你有用。

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

如果有什么需要我帮忙的,请随时通知我。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54039721

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档