1

我几乎已将所有东西都设置为通过 https 使用我的 WCF 服务。IIS 应用程序已启动并正在运行,我可以在 localhost 读取 svc 和 wsdl。于是我又回到Visual Studio,尝试写一个可以调用服务的Client。添加 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>

我究竟做错了什么?

4

1 回答 1

0

似乎 VS 没有找到正确的地址,因为它遗漏了应用程序部分。所以服务参考的正确地址是:

https://localhost/IISHostedSmartCook/SmartCookService.svc

于 2011-02-11T20:29:31.583 回答