简体   繁体   English

WCF服务在服务器上部署时显示错误

[英]wcf service showing error when deployed on server

I have a wcf service which is running fine on my localhost, now the issue is that when I try to deploy it on server it gives me the following error: 我有一个在我的本地主机上运行良好的wcf服务,现在的问题是,当我尝试在服务器上部署它时,出现以下错误:

Could not find a base address that matches scheme http for the endpoint with binding MetadataExchangeHttpBinding. 找不到与绑定MetadataExchangeHttpBinding的端点的方案http匹配的基地址。 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-service on server is configured like this: 服务器上的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>

While as webservice on my local host is configured like this: 作为本地主机上的网络服务配置为:

<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>

I am not able to figure out why it is running smoothly on localhost but shows error on server. 我无法弄清为什么它可以在本地主机上顺利运行,但是在服务器上显示错误。

The reason you're getting this error is that you're exposing an endpoint over webHttpBinding but specifying you want a WSDL definition exposed also. 出现此错误的原因是,您正在通过webHttpBinding公开端点,但指定您还希望公开WSDL定义。

Metadata endpoints are used for endpoints exposed over SOAP bindings, like basicHttpBinding or wcHttpBinding. 元数据端点用于通过SOAP绑定(例如basicHttpBinding或wcHttpBinding)公开的端点。 So if you want to use webHttpBinding you cannot have a mex binding defined. 因此,如果要使用webHttpBinding,则无法定义mex绑定。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 “由于内部错误,服务器无法处理请求”。 WCF 服务,在 IIS 上部署时 - 'The server was unable to process the request due to an internal error'. WCF Service, when deployed on IIS 部署后,Silverlight WCF服务不起作用 - Silverlight WCF service not working when deployed WCF在与asp.net应用程序位于同一服务器上部署的服务上给出跨域错误 - WCF giving cross-domain error on a service deployed on the same server as an asp.net application 调用WCF服务时已部署的Silverlight应用程序异常 - Deployed Silverlight application exception when calling a WCF Service 在IIS中承载WCF服务会导致错误“在应用程序中显示模式对话框或窗体……” - Hosting WCF service in IIS cause an error “Showing a modal dialog box or form when the application…” “/”应用程序中的服务器错误。 无法找到该资源。 (404) 将 WCF 服务部署到 Azure 应用服务时 - Server Error in '/' Application. The resource cannot be found. (404) when deploying WCF service to Azure App Service WCF 休息服务 500 内部服务器错误 - WCF rest service 500 internal server error 远程服务器返回错误:NotFound WCF服务 - The remote server returned an error: NotFound WCF Service 添加接受JSON的WCF服务,服务器上的错误 - Adding a WCF service that accepts JSON, error on server WCF服务引发内部服务器错误 - WCF Service Throws Internal Server Error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM