wcf 服务在服务器上部署时显示错误
wcf service showing error when deployed on server
我有一个 wcf 服务,在我的本地主机上 运行 没问题,现在的问题是,当我尝试在服务器上部署它时,出现以下错误:
Could not find a base address that matches scheme http for the
endpoint with binding MetadataExchangeHttpBinding. Registered base
address schemes are [].
[InvalidOperationException: Could not find a base address that matches scheme http for the endpoint with binding MetadataExchangeHttpBinding. Registered base address schemes are [].]
System.ServiceModel.ServiceHostBase.MakeAbsoluteUri(Uri relativeOrAbsoluteUri, Binding binding, UriSchemeKeyedCollection baseAddresses) +16604769
System.ServiceModel.Description.ConfigLoader.LoadServiceDescription(ServiceHostBase host, ServiceDescription description, ServiceElement serviceElement, Action`1 addBaseAddress) +1082
System.ServiceModel.ServiceHostBase.ApplyConfiguration() +156
System.ServiceModel.ServiceHostBase.InitializeDescription(UriSchemeKeyedCollection baseAddresses) +215
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) +530
System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath) +1413
System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +50
System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +1172
[ServiceActivationException: The service '/HighriseSite/appservices.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 MetadataExchangeHttpBinding. Registered base address schemes are []..]
System.Runtime.AsyncResult.End(IAsyncResult result) +901424
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +178638
System.Web.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult ar) +107
服务器上的 Web 服务配置如下:
<system.serviceModel>
<serviceHostingEnvironment>
<baseAddressPrefixFilters>
<add prefix="http://49.50.72.21/HighriseSite/"/>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
<behaviors>
<serviceBehaviors>
<behavior name="AppServicesBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="JsonBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="AppServicesBehavior" name="AppServices">
<endpoint address="http://49.50.72.21/HighriseSite/AppServices.svc" binding="webHttpBinding" contract="IAppServices" behaviorConfiguration="JsonBehavior">
<identity>
<dns value="http://49.50.72.21/"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
</system.serviceModel>
虽然我本地主机上的网络服务配置如下:
<system.serviceModel>
<serviceHostingEnvironment>
<baseAddressPrefixFilters>
<add prefix="http://localhost:7378/HighriseeSite/"/>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
<behaviors>
<serviceBehaviors>
<behavior name="AppServicesBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="JsonBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="AppServicesBehavior" name="AppServices">
<endpoint address="http://localhost:7378/HighriseeSite/AppServices.svc" binding="webHttpBinding" contract="IAppServices" behaviorConfiguration="JsonBehavior">
<identity>
<dns value="http://localhost:7378/"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
</system.serviceModel>
我无法弄清楚为什么它在本地主机上 运行 顺利,但在服务器上显示错误。
您收到此错误的原因是您通过 webHttpBinding 公开端点,但指定您还希望公开 WSDL 定义。
元数据端点用于通过 SOAP 绑定公开的端点,例如 basicHttpBinding 或 wcHttpBinding。因此,如果您想使用 webHttpBinding,则不能定义 mex 绑定。
我有一个 wcf 服务,在我的本地主机上 运行 没问题,现在的问题是,当我尝试在服务器上部署它时,出现以下错误:
Could not find a base address that matches scheme http for the endpoint with binding MetadataExchangeHttpBinding. Registered base address schemes are [].
[InvalidOperationException: Could not find a base address that matches scheme http for the endpoint with binding MetadataExchangeHttpBinding. Registered base address schemes are [].]
System.ServiceModel.ServiceHostBase.MakeAbsoluteUri(Uri relativeOrAbsoluteUri, Binding binding, UriSchemeKeyedCollection baseAddresses) +16604769
System.ServiceModel.Description.ConfigLoader.LoadServiceDescription(ServiceHostBase host, ServiceDescription description, ServiceElement serviceElement, Action`1 addBaseAddress) +1082
System.ServiceModel.ServiceHostBase.ApplyConfiguration() +156
System.ServiceModel.ServiceHostBase.InitializeDescription(UriSchemeKeyedCollection baseAddresses) +215
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) +530
System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath) +1413
System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +50
System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +1172
[ServiceActivationException: The service '/HighriseSite/appservices.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 MetadataExchangeHttpBinding. Registered base address schemes are []..]
System.Runtime.AsyncResult.End(IAsyncResult result) +901424
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +178638
System.Web.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult ar) +107
服务器上的 Web 服务配置如下:
<system.serviceModel>
<serviceHostingEnvironment>
<baseAddressPrefixFilters>
<add prefix="http://49.50.72.21/HighriseSite/"/>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
<behaviors>
<serviceBehaviors>
<behavior name="AppServicesBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="JsonBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="AppServicesBehavior" name="AppServices">
<endpoint address="http://49.50.72.21/HighriseSite/AppServices.svc" binding="webHttpBinding" contract="IAppServices" behaviorConfiguration="JsonBehavior">
<identity>
<dns value="http://49.50.72.21/"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
</system.serviceModel>
虽然我本地主机上的网络服务配置如下:
<system.serviceModel>
<serviceHostingEnvironment>
<baseAddressPrefixFilters>
<add prefix="http://localhost:7378/HighriseeSite/"/>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
<behaviors>
<serviceBehaviors>
<behavior name="AppServicesBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="JsonBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="AppServicesBehavior" name="AppServices">
<endpoint address="http://localhost:7378/HighriseeSite/AppServices.svc" binding="webHttpBinding" contract="IAppServices" behaviorConfiguration="JsonBehavior">
<identity>
<dns value="http://localhost:7378/"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
</system.serviceModel>
我无法弄清楚为什么它在本地主机上 运行 顺利,但在服务器上显示错误。
您收到此错误的原因是您通过 webHttpBinding 公开端点,但指定您还希望公开 WSDL 定义。
元数据端点用于通过 SOAP 绑定公开的端点,例如 basicHttpBinding 或 wcHttpBinding。因此,如果您想使用 webHttpBinding,则不能定义 mex 绑定。