[英]WCF service App configuration error
我找不到有關此事的任何有用信息,所以在這里寫:
我創建了一個在開發中可以正常工作的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.. ---> 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>
您已經兩次聲明了serviceMetadata
,這不是必需的。 另外,您不想使用httpsGetUrl
(帶有http
地址)。
嘗試這個:
<serviceMetadata httpGetEnabled="true"
httpGetUrl="http://localhost:10001/ServiceName"
httpsGetEnabled="false"
/>
仍然不知道問題出在哪里,但是對於可能遇到此問題的其他人,我將為我解決問題。
首先,我在.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-> 4.0切換(VS 2013)。
希望可以幫助某人
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.