【问题标题】:C# WCF Service Application Base Address IssueC# WCF 服务应用程序基地址问题
【发布时间】:2016-09-16 23:18:16
【问题描述】:

我有一个将通过 IIS 部署的 WCF 服务应用程序。

该服务的开发 URL 是 http://localhost:42543/Loyalty.svc,但是当它发布到 Web 服务器时,该 URL 将是 http://ServerName:1066/Loyalty.svc

但是,当我导航到该 URL 时,我收到以下错误:

找不到与具有绑定 WSHttpBinding 的端点的方案 https 匹配的基地址。注册的基地址方案是 [http]。

说明:在执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。

异常详细信息:System.InvalidOperationException:找不到与具有绑定 WSHttpBinding 的端点的方案 https 匹配的基地址。注册的基地址方案是 [http]。

网站的 web.config 在这里:

 <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="wsSecureBinding">
          <security mode="TransportWithMessageCredential">
            <message clientCredentialType="UserName"/>
            <transport clientCredentialType="None" proxyCredentialType="None" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <services>
      <service behaviorConfiguration="default" name="IISService.Loyalty">
        <endpoint address="" binding="wsHttpBinding" bindingConfiguration="wsSecureBinding" name="secureService" contract="IISService.ILoyalty"/>      
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="default">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
          <serviceCredentials>
            <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="IISService.SecurityValidation, IISService"/>
          </serviceCredentials>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>

我还使用http://www.c-sharpcorner.com/UploadFile/manas1/implementing-username-password-security-in-wcf-service/ 此处概述的基本传输安全模型。

提前感谢您的帮助。

【问题讨论】:

  • 只是一个疯狂的猜测:您还没有为在 IIS 中托管服务的站点配置 https,对吧?

标签: c# web-services wcf iis


【解决方案1】:

听起来您没有为 HTTPS 配置各自的服务器。

IIS 需要配置带有 HTTPS 的端口绑定。看 https://msdn.microsoft.com/en-us/library/hh556232%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396

Cassini 不支持 SSL,因此无法工作。 IIS Express 需要在 Visual Studio 中打开 SSL。见http://www.codeproject.com/Tips/723357/Enabling-SSL-with-IIS-Express-in-Visual-Studio

【讨论】:

    猜你喜欢
    • 2013-09-14
    • 1970-01-01
    • 1970-01-01
    • 2011-01-02
    • 2017-07-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多