【问题标题】:Could not find a base address that matches scheme http for the endpoint with binding BasicHttpBinding找不到与具有绑定 BasicHttpBinding 的端点的方案 http 匹配的基地址
【发布时间】:2014-02-10 22:30:31
【问题描述】:

当我尝试访问我的服务时收到此消息:

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

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.InvalidOperationException: Could not find a base address that matches scheme http for the endpoint with binding BasicHttpBinding. Registered base address schemes are [https].

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 

[InvalidOperationException: Could not find a base address that matches scheme http for the endpoint with binding BasicHttpBinding. Registered base address schemes are [https].]
   System.ServiceModel.ServiceHostBase.MakeAbsoluteUri(Uri relativeOrAbsoluteUri, Binding binding, UriSchemeKeyedCollection baseAddresses) +17430541
   System.ServiceModel.Description.ConfigLoader.LoadServiceDescription(ServiceHostBase host, ServiceDescription description, ServiceElement serviceElement, Action`1 addBaseAddress, Boolean skipHost) +1097
   System.ServiceModel.ServiceHostBase.LoadConfigurationSectionInternal(ConfigLoader configLoader, ServiceDescription description, ServiceElement serviceSection) +89
   System.ServiceModel.ServiceHost.ApplyConfiguration() +162
   System.ServiceModel.ServiceHostBase.InitializeDescription(UriSchemeKeyedCollection baseAddresses) +207
   System.ServiceModel.ServiceHost..ctor(Type serviceType, Uri[] baseAddresses) +475
   System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(Type serviceType, Uri[] baseAddresses) +43
   System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses) +578
   System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath, EventTraceActivity eventTraceActivity) +1451
   System.ServiceModel.HostingManager.ActivateService(ServiceActivationInfo serviceActivationInfo, EventTraceActivity eventTraceActivity) +76
   System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath, EventTraceActivity eventTraceActivity) +901

[ServiceActivationException: The service '/fileservice/fileservice.svc' cannot be activated due to an exception during compilation.  The exception message is: Could not find a base address that matches scheme http for the endpoint with binding BasicHttpBinding. Registered base address schemes are [https]..]
   System.Runtime.AsyncResult.End(IAsyncResult result) +654324
   System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +210877
   System.Web.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar) +282

我使用的配置几乎与我在同一个 url 不同文件夹上编写的另一个服务相同,我没有任何问题。

这是我的 web.config:

 <?xml version="1.0" encoding="utf-8"?>
<configuration>

  <system.web>
    <compilation targetFramework="4.0" debug="true">
      <assemblies>
        <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      </assemblies>
    </compilation>
    <caching>
      <outputCacheSettings>
        <outputCacheProfiles>
          <add name="DefaultCache" duration="60" varyByParam="none" />
        </outputCacheProfiles>
      </outputCacheSettings>
    </caching>
  </system.web>

  <system.serviceModel>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" />
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpEndpointBinding">
          <security mode="None">
            <!-- Basic <security mode="Transport"> -->
            <!-- To use Basic auth, just comment Windows and use this, but you need to configure basic in IIS as well -->
            <!-- <transport clientCredentialType="Basic" /> -->
            <transport clientCredentialType="None" />
          </security>
        </binding>
      </basicHttpBinding>
      <webHttpBinding>
        <binding name="default">
          <security mode="None">
            <!-- Basic <security mode="Transport"> -->
            <!-- To use Basic auth, just comment Windows and use this -->
            <!-- <transport clientCredentialType="Basic" /> -->
            <transport clientCredentialType="None" />
          </security>
        </binding>
      </webHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="true" />
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="restBehavior">
          <webHttp />
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <services>
      <service name="FileStorageService.FileService">
        <endpoint binding="basicHttpBinding" bindingConfiguration="BasicHttpEndpointBinding" contract="FileStorageService.IFileService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="rest" binding="webHttpBinding" bindingConfiguration="default" behaviorConfiguration="restBehavior" contract="FileStorageService.IFileService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
      </service>
    </services>
  </system.serviceModel>

  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
  </system.webServer>

</configuration>

我唯一改变的是命名空间和服务名称。该服务的命名空间为FileStorageService,服务名称为FileService

我在服务器上真的什么都没有,你可以在代码中看到:

using System.ServiceModel;

namespace FileStorageService
{
  // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IFileService" in both code and config file together.
  [ServiceContract]
  public interface IFileService
  {
    [OperationContract]
    void DoWork();
  }
}

namespace FileStorageService
{
  // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "FileService" in code, svc and config file together.
  public class FileService : IFileService
  {
    public void DoWork()
    {
    }
  }
}

这是创建新服务时的基本信息。它正在发布到 SSL 域,因此需要 https。

我要做的就是将它发布,这样我就知道它正在工作,所以我可以继续前进。

谁能看出我做错了什么?

【问题讨论】:

  • 您尝试过 Jon Barker 解决方案吗?

标签: c# wcf web-services iis-7


【解决方案1】:

我没有代表发表评论,所以这里有一个评论作为答案......

我认为问题在于您正在尝试托管基于 SSL 的服务,但您的绑定配置没有传输安全类型。您需要修改基本绑定的安全模式以支持传输安全。答案请看这里:

WCF Exception: Could not find a base address that matches scheme http for the endpoint

如果这没有帮助,请先尝试将服务托管为非基于 HTTPS 的服务,然后看看是否可行。这将验证您的其余配置是否正确。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2020-06-02
  • 2021-06-02
  • 1970-01-01
  • 2011-10-14
  • 2012-04-06
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多