WCF服务应用程序配置错误

时间:2014-05-27 07:31:07

标签: c# .net wcf

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

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

  

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

App是.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>

2 个答案:

答案 0 :(得分:1)

您已声明serviceMetadata两次,这是没有必要的。此外,您还提供httpsGetUrlhttp地址)而您不想使用它。

试试这个:

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

答案 1 :(得分:0)

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

首先我在.Net 4.5中完成了这项服务,但由于IIS只支持ASP.NET 4.0,我只需更改目标框架就可以将其转换为4.0

我使用.Net 4.0从头开始再次提供整个服务,这对webconfig来说很有用,它更容易使用:

Factory="System.ServiceModel.Activation.WebServiceHostFactory"

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

所以我的结论是从.Net framework 4.5转换 - &gt; 4.0是导致问题的原因(VS 2013)。

希望帮助某人