Server error in WCF [closed]

2020-08-09 04:20发布

I am getting this error:

Server Error in '/cms' Application.

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 Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details:

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

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[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.UriSchemeKeyedCollection.InsertItem(Int32 index, Uri item) +16395359 System.Collections.Generic.SynchronizedCollection`1.Add(T item) +79 System.ServiceModel.UriSchemeKeyedCollection..ctor(Uri[] addresses) +222 System.ServiceModel.ServiceHost..ctor(Type serviceType, Uri[] baseAddresses) +346 System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(Type serviceType, Uri[] baseAddresses) +43 System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses) +530 System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath) +1413 System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +50 System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +1172

[ServiceActivationException: The service '/cms/service.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.Runtime.AsyncResult.End(IAsyncResult result) +901424 System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +178702 System.Web.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult ar) +107

-------------------------------------------------------------------------------- Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.237

What am I doing wrong?

标签: wcf
2条回答
成全新的幸福
2楼-- · 2020-08-09 04:45

Is there a service with multiple endpoints in your web.config file? If there are multiple endpoints for a single service (In section), then only one endpoint can have no address attribute set. The other endpoints need to have the address setting.

From the client side, if you want to use the endpoint with the new endpoint address, you need to include it in the address, such as "http://localhost/cms/Service.svc/newEP"

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

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

查看更多
神经病院院长
3楼-- · 2020-08-09 04:57

As Steven Cheng once said:

Based on my understanding, this error is expected when the WCF's IIS hosting site has multiple host header associated with it (while WCF host can accept only one base address for each transport scheme).

He suggested a good blog entry explaining this problem and the resolution:

..I'd link to the source but I've lost it...

查看更多
登录 后发表回答