【发布时间】:2012-04-14 00:28:39
【问题描述】:
也许你可以帮助我,因为我在这里真的很茫然。
我正在尝试在子域的 IIS 上托管我的 WCF 服务。
首先,这是我的文件结构:
http://s18.postimage.org/eqmjxb00n/Serv.jpg
bin 里面是我的 .dll,代表我的接口和它的实现。
这是 web.config 文件:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="false" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="AuthenticatorService.Authenticator">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration=""
name="AuthEndpoint" contract="AuthInterface.IAuthenticator" />
<endpoint address="" binding="mexHttpBinding" name="MetadataEndpoint"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
它可以在本地工作,但是当我上传到 IIS 时,它只会出现 500 个服务器错误。
谢谢!
如果有任何用处,这里是来自详细错误页面的消息:
Module ServiceModel-4.0
Notification AuthenticateRequest
Handler svc-Integrated-4.0
Error Code 0x00000000
Requested URL http://service.swiftposter.com:80/auth.svc
Logon Method Anonymous
Logon User Anonymous
编辑:我启用了 ELMAH 日志记录,最后得到了一条有意义的消息:
System.ArgumentException: This collection already contains an address with scheme http. There can be at most one address per scheme in this collection. If your service is being hosted in IIS you can fix the problem by setting 'system.serviceModel/serviceHostingEnvironment/multipleSiteBindingsEnabled' to true or specifying 'system.serviceModel/serviceHostingEnvironment/baseAddressPrefixFilters'. Parameter name: item
我打算开始研究这个错误,但我在这里发布以防万一有人知道出了什么问题。
堆栈跟踪:
System.ServiceModel.ServiceActivationException: The service '/auth.svc' cannot be activated due to an exception during compilation. The exception message is: This collection already contains an address with scheme http. There can be at most one address per scheme in this collection. If your service is being hosted in IIS you can fix the problem by setting 'system.serviceModel/serviceHostingEnvironment/multipleSiteBindingsEnabled' to true or specifying 'system.serviceModel/serviceHostingEnvironment/baseAddressPrefixFilters'.
Parameter name: item. ---> System.ArgumentException: This collection already contains an address with scheme http. There can be at most one address per scheme in this collection. If your service is being hosted in IIS you can fix the problem by setting 'system.serviceModel/serviceHostingEnvironment/multipleSiteBindingsEnabled' to true or specifying 'system.serviceModel/serviceHostingEnvironment/baseAddressPrefixFilters'.
Parameter name: item
at System.ServiceModel.UriSchemeKeyedCollection.InsertItem(Int32 index, Uri item)
at System.Collections.Generic.SynchronizedCollection`1.Add(T item)
at System.ServiceModel.UriSchemeKeyedCollection..ctor(Uri[] addresses)
at System.ServiceModel.ServiceHost..ctor(Type serviceType, Uri[] baseAddresses)
at System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(Type serviceType, Uri[] baseAddresses)
at System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses)
at System.ServiceModel.ServiceHostingEnvironment.HostingManager.CreateService(String normalizedVirtualPath)
at System.ServiceModel.ServiceHostingEnvironment.HostingManager.ActivateService(String normalizedVirtualPath)
at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath)
--- End of inner exception stack trace ---
at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result)
at System.ServiceModel.Activation.ServiceHttpModule.EndProcessRequest(IAsyncResult ar)
at System.Web.HttpApplication.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult ar)
【问题讨论】:
-
在 IIS 中部署时没有任何反应?您在问题标题中提到了一些 500 服务器错误。你能告诉我们更多关于它的信息吗?
-
对不起,什么也没发生,我的意思是它没有运行。它只是不断给我 500 个服务器错误。
-
是应用程序池定义权限的 .net 版本,是使用正确凭据颁发的文件/数据库(如果适用)。几个问题可能是问题所在。你有更多信息吗?
-
设置为4.0,所有文件都可以访问
-
这个旧线程对我很有用。我的网站有一个旧的 asp.net 应用程序以及一些 WCF 服务 - 这些 WCF 服务已经运行了好几年,但昨天中午突然停止工作。在徒劳地尝试了几个小时之后,遇到了TheGateKeeper's answer above,应用了它,这解决了我的问题。如果这对任何人都有帮助 - 我不能 100% 确定其根本原因,但这是我在撰写本文时的最佳猜测: - 我的 WCF 服务可能需要设置
multipleSiteBindingsEnabled