【问题标题】:WCF service App configuration errorWCF 服务应用程序配置错误
【发布时间】:2014-05-27 07:31:06
【问题描述】:

我没有找到任何有用的信息,所以我写在这里:

我创建了一个在开发中运行良好的 WCF 服务应用程序,但是当我部署它时,我在 IIS (7.0) 上收到此错误:

ServiceMetadataBehavior的HttpsGetEnabled属性设置为true,HttpsGetUrl属性是相对地址,但是没有https基地址。提供 https 基地址或将 HttpsGetUrl 设置为绝对地址。

应用程序是 .Net FW 4.0,IIS 应用程序池是 ASP.NET v4.0

web.config:

  <service name="ServiceName.Service1">
    <endpoint address=""
              behaviorConfiguration="restfulBehavior" 
              binding="webHttpBinding" 
              contract="ServiceName.IServiceApp"/>
  </service>

<serviceMetadata httpGetEnabled="true" 
                 httpGetUrl="http://localhost:10001/ServiceName"  
                 httpsGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="false" />

希望有人可以帮助解决这个问题。

Windows Event Log:
Log Name:      Application
Source:        System.ServiceModel 4.0.0.0
Date:          28.5.2014 0:11:19
Event ID:      3
Task Category: WebHost
Level:         Error
Keywords:      Classic
User:          IIS APPPOOL\ASP.NET v4.0
Computer:      Server.domain.local
Description:
WebHost failed to process a request.
 Sender Information: System.ServiceModel.ServiceHostingEnvironment+HostingManager/3486411
 Exception: System.ServiceModel.ServiceActivationException: The service '/ServiceApp/ServiceName.svc' cannot be activated due to an exception during compilation.  The exception message is: The HttpsGetEnabled property of ServiceMetadataBehavior is set to true and the HttpsGetUrl property is a relative address, but there is no https base address.  Either supply an https base address or set HttpsGetUrl to an absolute address.. ---> System.InvalidOperationException: The HttpsGetEnabled property of ServiceMetadataBehavior is set to true and the HttpsGetUrl property is a relative address, but there is no https base address.  Either supply an https base address or set HttpsGetUrl to an absolute address.
   at System.ServiceModel.Description.ServiceMetadataBehavior.EnsureGetDispatcher(ServiceHostBase host, ServiceMetadataExtension mex, Uri url, String scheme)
   at System.ServiceModel.Description.ServiceMetadataBehavior.CreateHttpGetEndpoints(ServiceDescription description, ServiceHostBase host, ServiceMetadataExtension mex)
   at System.ServiceModel.Description.ServiceMetadataBehavior.ApplyBehavior(ServiceDescription description, ServiceHostBase host)
   at System.ServiceModel.Description.ServiceMetadataBehavior.System.ServiceModel.Description.IServiceBehavior.ApplyDispatchBehavior(ServiceDescription description, ServiceHostBase serviceHostBase)
   at System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(ServiceDescription description, ServiceHostBase serviceHost)
   at System.ServiceModel.ServiceHostBase.InitializeRuntime()
   at System.ServiceModel.ServiceHostBase.OnBeginOpen()
   at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.ActivateService(String normalizedVirtualPath)
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath)
   --- End of inner exception stack trace ---
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath)
   at System.ServiceModel.ServiceHostingEnvironment.EnsureServiceAvailableFast(String relativeVirtualPath)
 Process Name: w3wp
 Process ID: 4520

Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
  <System>
    <Provider Name="System.ServiceModel 4.0.0.0" />
    <EventID Qualifiers="49154">3</EventID>
    <Level>2</Level>
    <Task>5</Task>
    <Keywords>0x80000000000000</Keywords>
    <TimeCreated SystemTime="2014-05-27T22:11:19.000000000Z" />
    <EventRecordID>64475</EventRecordID>
    <Channel>Application</Channel>
    <Computer>Server.domain.local</Computer>
    <Security UserID="bla bla bla" />
  </System>
  <EventData>
    <Data>System.ServiceModel.ServiceHostingEnvironment+HostingManager/3486411</Data>
    <Data>System.ServiceModel.ServiceActivationException: The service '/ServiceApp/ServiceName.svc' cannot be activated due to an exception during compilation.  The exception message is: The HttpsGetEnabled property of ServiceMetadataBehavior is set to true and the HttpsGetUrl property is a relative address, but there is no https base address.  Either supply an https base address or set HttpsGetUrl to an absolute address.. ---&gt; System.InvalidOperationException: The HttpsGetEnabled property of ServiceMetadataBehavior is set to true and the HttpsGetUrl property is a relative address, but there is no https base address.  Either supply an https base address or set HttpsGetUrl to an absolute address.
   at System.ServiceModel.Description.ServiceMetadataBehavior.EnsureGetDispatcher(ServiceHostBase host, ServiceMetadataExtension mex, Uri url, String scheme)
   at System.ServiceModel.Description.ServiceMetadataBehavior.CreateHttpGetEndpoints(ServiceDescription description, ServiceHostBase host, ServiceMetadataExtension mex)
   at System.ServiceModel.Description.ServiceMetadataBehavior.ApplyBehavior(ServiceDescription description, ServiceHostBase host)
   at System.ServiceModel.Description.ServiceMetadataBehavior.System.ServiceModel.Description.IServiceBehavior.ApplyDispatchBehavior(ServiceDescription description, ServiceHostBase serviceHostBase)
   at System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(ServiceDescription description, ServiceHostBase serviceHost)
   at System.ServiceModel.ServiceHostBase.InitializeRuntime()
   at System.ServiceModel.ServiceHostBase.OnBeginOpen()
   at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.ActivateService(String normalizedVirtualPath)
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath)
   --- End of inner exception stack trace ---
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath)
   at System.ServiceModel.ServiceHostingEnvironment.EnsureServiceAvailableFast(String relativeVirtualPath)</Data>
    <Data>w3wp</Data>
    <Data>4520</Data>
  </EventData>
</Event>

【问题讨论】:

  • httpsGetUrl 不应该以https: 开头吗?
  • 是的,也尝试过(编辑),但没有帮助仍然是同样的错误,比如它没有读取我什至搜索过的设置,如果我在应用程序的其他地方有 ServiceMetadata 但没有。所以它有点像 IIS 没有从配置文件中读取设置
  • 添加了端点配置由于某种原因不能将整个 webconfig 放在这里。希望它可以帮助有人帮助我解决这个问题

标签: c# .net wcf


【解决方案1】:

您已经声明了两次serviceMetadata,这不是必需的。此外,您提供了一个httpsGetUrl(带有http 地址),而您不想使用它。

试试这个:

<serviceMetadata httpGetEnabled="true"
                 httpGetUrl="http://localhost:10001/ServiceName"
                 httpsGetEnabled="false"
/>

【讨论】:

  • 试过但还是一样 :( 还尝试了带有文件夹路径和 .svc 文件路径的 Url,但没有区别
【解决方案2】:

仍然不知道这是什么问题,但对于可能出现此问题的其他人,我会发布为我解决的问题。

首先我在 .Net 4.5 中完成了该服务,但由于 IIS 仅支持 ASP.NET 4.0,我通过更改目标框架将其转换为 4.0

我使用 .Net 4.0 从头开始​​重新创建了整个服务,就 webconfig 而言,它更容易使用:

Factory="System.ServiceModel.Activation.WebServiceHostFactory"

并从 WebConfig 中删除 system.serviceModel 元素。

所以我的结论是从 .Net 框架 4.5 -> 4.0 切换是导致问题的原因(VS 2013)。

希望能帮助别人

【讨论】:

    猜你喜欢
    • 2011-12-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-28
    • 2016-02-01
    • 1970-01-01
    • 2011-01-20
    • 1970-01-01
    相关资源
    最近更新 更多