也许你可以帮助我,因为我在这里真的很茫然。
我正在尝试在子域上的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)
答案 0 :(得分:3)
我通过将此错误添加到我的web.config来修复错误。
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
我认为这是因为我有2个绑定都使用了http。也许其他人可以详细说明。
答案 1 :(得分:0)
错误500识别任何类型的服务器错误...尝试从localhost访问服务(IIS的默认设置仅在本地显示错误)。
还尝试将IIS设置编辑为“向浏览器发送错误” 要么 在Internet信息服务(IIS)管理器中&gt;您的网络&gt;错误页面&gt;属性并选择详细错误
通过这种方式,您可以看到服务引发的实际错误。
还要检查在应用程序池中是否选择了正确的框架版本
答案 2 :(得分:0)
您的服务地址和服务的元数据地址不应相同。应该是这样的:
<system.serviceModel>
<services>
<service name="AuthenticatorService.Authenticator">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration=""
name="AuthEndpoint" contract="AuthInterface.IAuthenticator" />
<endpoint address="mex" binding="mexHttpBinding" name="MetadataEndpoint"
contract="IMetadataExchange" />
</service>
</services>
...
</system.serviceModel>