Мне не удалось найти полезную информацию по этому вопросу, поэтому я пишу здесь:
Я создал приложение службы WCF, которое отлично работает в разработке, но когда я его развертываю, я получаю эту ошибку в IIS (7.0):
Свойству HttpsGetEnabled для ServiceMetadataBehavior установлено значение 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>
Все еще не знаю, в чем проблема с этим, но для других людей, которые могли бы прийти сюда, я опубликую то, что решило это для меня.
Сначала я выполнил эту услугу в.NET 4.5, но поскольку IIS поддерживает только ASP.NET 4.0, я преобразовал ее после версии 4.0, просто изменив целевую структуру
Я сделал всю услугу с нуля с помощью.Net 4.0, и это сработало до тех пор, пока Webconfig работает гораздо проще:
Factory="System.ServiceModel.Activation.WebServiceHostFactory"
И удалите элемент system.serviceModel
alltogether из WebConfig.
Поэтому я пришел к выводу, что причиной отказа стала проблема с.Net framework 4.5 → 4.0 (VS 2013).
Надежда помогает кому-то
Вы дважды объявили serviceMetadata
, что необязательно. Кроме того, вы предоставляете httpsGetUrl
(с адресом http
), пока вы не хотите его использовать.
Попробуй это:
<serviceMetadata httpGetEnabled="true"
httpGetUrl="http://localhost:10001/ServiceName"
httpsGetEnabled="false"
/>