找不到与IIS托管的WCF中的方案HTTPS错误匹配的基址

时间:2011-02-08 19:56:01

标签: wcf iis-7 https mex wshttpbinding

我几乎已将所有设置为通过https使用我的WCF服务。 IIS应用程序启动并运行,我可以在localhost上读取svc和wsdl。所以我回到Visual Studio并尝试编写可以调用该服务的客户端。添加ServiceReference时,出现以下错误:

无法找到与绑定MetadataExchangeHttpsBinding的端点的方案https匹配的基址。注册的基地址方案是[http]。

我已尝试使用内置开发服务器和IIS Express。他们都犯了同样的错误。

这是我的web.config:

<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="TransportSecurity">
          <security mode="Transport">
            <transport clientCredentialType="None" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="SmartCook2.Server.ISmartCookServiceBehavior">
          <serviceMetadata httpsGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
    <services>
      <service behaviorConfiguration="SmartCook2.Server.ISmartCookServiceBehavior" 
        name="SmartCook2.Server.SmartCookService">
        <endpoint address="https://localhost:6344/SmartCookService.svc" 
          binding="wsHttpBinding" bindingConfiguration="TransportSecurity" 
          contract="SmartCook2.Server.ISmartCookService" />
        <endpoint address="mex" binding="mexHttpsBinding" 
          contract="IMetadataExchange" />
      </service>
    </services>
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
</configuration>

我做错了什么?

1 个答案:

答案 0 :(得分:0)

似乎VS没有正确发现地址,因为它遗漏了应用程序部分。因此服务引用的正确地址是:

https://localhost/IISHostedSmartCook/SmartCookService.svc