2012-03-30 102 views
1

也许你可以帮助我,因为我在这里真的很茫然。托管WCF时发生服务器错误

我想在子域上的IIS上托管我的WCF服务。

开始,这里是我的文件结构:

http://s18.postimage.org/eqmjxb00n/Serv.jpg

垃圾桶里面是代表我的界面我.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记录和终于拿到了meaningfull消息:

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

在IIS中部署时没有任何反应?你在问题标题中提到了500个服务器错误。你能告诉我们更多一点吗? – 2012-03-30 10:14:50

+0

对不起,没有任何反应,我的意思是它没有运行。它只是不断给我500服务器错误。 – TheGateKeeper 2012-03-30 10:17:33

+0

是。净版本的应用程序池定义的权限是文件/数据库使用正确的凭据发布(如果适用)。问题可能是问题。你有更多的信息吗? – 2012-03-30 10:30:15

回答

3

我加入这我的web.config固定的错误。

<serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 

我认为这是因为我有两个绑定,它们都使用http。也许别人可以详细说明。

0

错误500标识的任何类型的服务器错误...尝试从本地主机访问服务(IIS的默认设置显示错误只在本地)。

也尝试编辑IIS设置为“错误发送到浏览器” 或 在Internet信息服务(IIS)管理器>你的网络>错误页>属性,然后选择详细信息的错误

通过这种方式,你可以查看您的服务引发的真实错误。

检查也说,在你的应用程序池,正确的架构版本选择

+0

我已经尝试启用错误。它没有给我任何信息,只是一般性错误。 – TheGateKeeper 2012-03-30 10:37:28

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> 

http://msdn.microsoft.com/en-us/library/ms733766.aspx

+0

嗨,我尝试通过设置两个地址属性,但它仍然无法正常工作。同样的错误。 – TheGateKeeper 2012-03-30 12:38:53

+0

不确定,但你可以检查这个博客吗?与你类似的错误。 [http://net.micheltol.nl/post/-The-service-SampleSampleServicesvc-cannot-be-activated-due-to-an-exception-during-compilation-The-exception-message-is-This-collection-已经包含-的地址与 - 方案-HTTP-有-可以待在最一地址每方案 - 在 - 这 - collection.aspx] – 2012-03-30 12:53:06