2012-03-30 73 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