我試圖在同一網站內使用兩個端點一個HTTP和另一個HTTPS託管相同的服務。當爲HTTPS和HTTP託管相同的服務時,「URI的註冊已存在」
問題是我可以愉快地打電話給一個服務(無論我先打電話的第一個作品),但然後調用其他服務失敗,直到我iisreset並再次嘗試。因此,我可以愉快地一次調用兩種方法,直到一個過程回收。
我已經用盡了所有相關的Q & A和我能找到的文件,而且他們都沒有幫助我。 MSDN關於這些案例的文檔級別(這應該是不常見的)令人震驚,而且看起來沒有任何效果。
我已經使用Host/BaseAddresses/BaseAddress沒有運氣,每當我使用它,我得到另一個錯誤(無法找到HTTPS方案)。
我有一個名爲Secure的文件夾,它啓用了IIS中的HTTPS。
我已禁用mex,因此沒有允許我通過以前的錯誤的元數據。
任何人都有線索?我cluless ...
<service name="Namespace.MyService" behaviorConfiguration="MyBehaviour">
<host>
<baseAddresses>
</baseAddresses>
</host>
<endpoint address="http://localhost/Services/MyService.svc/MyService"
name="MyService" binding="wsHttpBinding"
bindingConfiguration="myWsHttpBinding" contract="Namespace.IMyService" />
<endpoint address="https://localhost/Services/Secure/MySslService.svc/MySslService"
name="MySslService" binding="basicHttpBinding"
bindingConfiguration="MySslServiceBinding" contract="Namespace.IMyService" />
</service>
.....
<behavior name="MyBehaviour">
<custom1/>
<custom2/>
<serviceMetadata httpGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="false"/>
<serviceAuthorization principalPermissionMode="UseAspNetRoles" roleProviderName="CustomProvider"/>
<serviceCredentials>
<serviceCertificate findValue="Some" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" />
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="SomeClass, SomeDll"/>
</serviceCredentials>
</behavior>
原來的錯誤是:
A registration already exists for URI 'http://localhost/Services/....'.
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.InvalidOperationException: A registration already exists for URI 'http://localhost/Services/....'.
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:
[InvalidOperationException: A registration already exists for URI
System.ServiceModel.Channels.UriPrefixTable1.RegisterUri(Uri uri, HostNameComparisonMode hostNameComparisonMode, TItem item) +320 System.ServiceModel.Channels.HttpTransportManager.Register(TransportChannelListener channelListener) +380
2.OnOuterListenerOpen(ChannelDemuxerFilter filter, IChannelListener listener, TimeSpan timeout) +606
System.ServiceModel.Channels.TransportManager.Open(TransportChannelListener channelListener) +816
System.ServiceModel.Channels.TransportManagerContainer.Open(SelectTransportManagersCallback selectTransportManagerCallback) +121
System.ServiceModel.Channels.HttpChannelListener.OnOpen(TimeSpan timeout) +125
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +789
System.ServiceModel.Channels.DatagramChannelDemuxer
System.ServiceModel.Channels.SingletonChannelListener`3.OnOpen(TimeSpan timeout) +91
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +789
System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout) +375
這裏是WCF跟蹤日誌錯誤:
The ChannelDispatcher at 'http://localhost/Services/...' with contract(s) '"IMyService"' is unable to open its IChannelListener. System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout) System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout) System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) System.ServiceModel.ServiceHostingEnvironment.HostingManager.ActivateService(String normalizedVirtualPath) System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) System.ServiceModel.ServiceHostingEnvironment.EnsureServiceAvailableFast(String relativeVirtualPath) System.ServiceModel.Activation.HostedHttpRequestAsyncResult.HandleRequest() System.ServiceModel.Activation.HostedHttpRequestAsyncResult.BeginRequest() System.ServiceModel.Activation.HostedHttpRequestAsyncResult.OnBeginRequest(Object state) System.ServiceModel.AspNetPartialTrustHelpers.PartialTrustInvoke(ContextCallback callback, Object state) System.ServiceModel.Activation.HostedHttpRequestAsyncResult.OnBeginRequestWithFlow(Object state) System.Runtime.IOThreadScheduler.ScheduledOverlapped.IOCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped) System.Runtime.Fx.IOCompletionThunk.UnhandledExceptionFrame(UInt32 error, UInt32 bytesRead, NativeOverlapped* nativeOverlapped) System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
謝謝。我明天會給它一個非嵌套結構,雖然它定義的方式有點複雜,我必須保證一個文件夾的安全,但這是可能的。 – Aliostad 2010-12-07 23:22:39