https环境下的WCF服务

https环境下的WCF服务,https,wcf,Https,Wcf,我已经创建并测试了WCF服务,一切正常 当我部署到测试环境并尝试打开时,我收到错误消息: 找不到一个 匹配端点的http方案 有约束力 MetadataExchangeHttpBinding。 注册基址方案包括 [https] Internet显示我需要添加更多配置选项: 我已经在serviceweb.config文件中添加了一些设置。现在看起来是这样的: <system.serviceModel> <services> <service name="McAc

我已经创建并测试了WCF服务,一切正常

当我部署到测试环境并尝试打开时,我收到错误消息:

找不到一个 匹配端点的http方案 有约束力 MetadataExchangeHttpBinding。 注册基址方案包括 [https]

Internet显示我需要添加更多配置选项:

我已经在serviceweb.config文件中添加了一些设置。现在看起来是这样的:

<system.serviceModel>
<services>
  <service name="McActivationApp.EnrollmentService" behaviorConfiguration="McActivationApp.EnrollmentServicBehavior">
    <endpoint 
      address="https://my.site/myapp/EnrollmentService.svc"
      binding="basicHttpBinding"
      bindingConfiguration="TransportSecurity"
      contract="McActivationApp.IEnrollmentService"/>
    <endpoint address="mex" binding="mexHttpBinding" contract="McActivationApp.IEnrollmentService" />
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="McActivationApp.EnrollmentServicBehavior">
      <serviceMetadata httpGetEnabled="True"/>
      <serviceDebug includeExceptionDetailInFaults="False" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<bindings>
  <basicHttpBinding>
    <binding name="TransportSecurity">
      <security mode="Transport">
        <transport clientCredentialType="None" />
      </security>
    </binding>
  </basicHttpBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
</system.serviceModel>

实际上,我已经添加了“bindings”部分,并为端点指定了它

但这并没有改变什么

请告诉我,我需要做什么。非常感谢


注意:在使用https和http资源的WCF服务方面有什么不同吗?

若要通过允许http解决此问题,您需要在IIS中添加http绑定:

  • 在IIS中导航到您的站点
  • 单击右侧“操作”面板中的“绑定…”
  • 单击“添加”
  • 选择“http”并确定输出
  • 或者,您可以通过删除行或更改以下内容来防止出现问题:

    <serviceMetadata httpGetEnabled="True"/>
    
    
    
    致:


    您已获得http元数据端点,应将其更改为https,如下所示

    <serviceMetadata httpsGetEnabled="True"/>  
    
    
    

    此外,如果没有必要,您应该从生产中删除mex和https元数据端点,作为最佳做法。

    如果您希望仅通过https公开您的服务(站点根本不支持HTTP),则不能使用依赖于HTTP的任何内容。您当前的配置公开了HTTP上的帮助页面,也公开了HTTP上的mex端点(使用错误的契约)。所以试试这个:

    <system.serviceModel> 
      <services>   
        <service name="McActivationApp.EnrollmentService" behaviorConfiguration="McActivationApp.EnrollmentServicBehavior">     
          <endpoint address="" binding="basicHttpBinding" bindingConfiguration="TransportSecurity" contract="McActivationApp.IEnrollmentService"/>     
          <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />   
        </service> 
      </services> 
      <behaviors>   
        <serviceBehaviors>     
          <behavior name="McActivationApp.EnrollmentServicBehavior">         
            <serviceMetadata httpsGetEnabled="True"/>       
            <serviceDebug includeExceptionDetailInFaults="False" />     
          </behavior>   
        </serviceBehaviors> 
      </behaviors> 
      <bindings>   
        <basicHttpBinding>     
          <binding name="TransportSecurity">       
            <security mode="Transport">         
              <transport clientCredentialType="None" />       
            </security>     
          </binding>   
        </basicHttpBinding> 
      </bindings> 
      <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />      
    </system.serviceModel>
    
    
    
    我是否正确理解我需要将其添加到“”中?因此,我可以针对这种情况删除http绑定吗?如果添加此属性并删除绑定“serviceMetadata”,我会收到相同的错误消息…请注意,我还需要更改的是删除(注意:属性名称不包含“s”)要删除“mex”端点…这就是我的意思,从httpGetEnabled更改为httpGetEnabled…但是…更改后,网站开始在通常不允许的“http”下工作…我是否正确理解您的意思:1)将mex绑定从mexHttpBinding更改为mexHttpBinding,2)将httpGetEnabled替换为httpGetEnabledled。对吗?是的,它也可以工作。谢谢这就是我所做的+更改了mex的合同并删除了第一个端点的地址,因为在IIS中托管服务时不使用它。谢谢-Ladislav Mrnka。我花了6个小时找到了您的解决方案。非常感谢。@LadislavMrnka如果我理解正确,这里的绑定是BasichtpBinding,不起任何作用通过https保护服务的安全。重要的是安全模式是“传输”,对吗?
    <system.serviceModel> 
      <services>   
        <service name="McActivationApp.EnrollmentService" behaviorConfiguration="McActivationApp.EnrollmentServicBehavior">     
          <endpoint address="" binding="basicHttpBinding" bindingConfiguration="TransportSecurity" contract="McActivationApp.IEnrollmentService"/>     
          <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />   
        </service> 
      </services> 
      <behaviors>   
        <serviceBehaviors>     
          <behavior name="McActivationApp.EnrollmentServicBehavior">         
            <serviceMetadata httpsGetEnabled="True"/>       
            <serviceDebug includeExceptionDetailInFaults="False" />     
          </behavior>   
        </serviceBehaviors> 
      </behaviors> 
      <bindings>   
        <basicHttpBinding>     
          <binding name="TransportSecurity">       
            <security mode="Transport">         
              <transport clientCredentialType="None" />       
            </security>     
          </binding>   
        </basicHttpBinding> 
      </bindings> 
      <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />      
    </system.serviceModel>