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

发布于 2024-10-16 11:48:51 字数 1930 浏览 2 评论 0原文

我几乎已经完成了通过 https 使用 WCF 服务的所有设置。 IIS 应用程序已启动并正在运行,我可以在本地主机上读取 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>

我做错了什么?

I almost have everything set up to use my WCF service over https. IIS application is up and running, I can read the svc and wsdl at localhost. So I went back to Visual Studio and tried to write a Client that can call the service. When adding the ServiceReference I get the following error:

Could not find a base address that matches scheme https for the endpoint with binding MetadataExchangeHttpsBinding. Registered base address schemes are [http].

I've tried with the built-in development server and with IIS Express also. They both gave the same error.

Here's my 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>

What am I doing wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

愿得七秒忆 2024-10-23 11:48:51

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

https://localhost/IISHostedSmartCook/SmartCookService.svc

It seems VS didn't discover the address right, since it left out the application part. So the correct address for the service reference is :

https://localhost/IISHostedSmartCook/SmartCookService.svc

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文