"注册已存在的URI"托管相同服务时,HTTPS和HTTP [英] "A registration already exists for URI" when hosting same service for HTTPS and HTTP

查看:1061
本文介绍了"注册已存在的URI"托管相同服务时,HTTPS和HTTP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用主持两个端点的HTTP和HTTPS等同一网站内同样的服务。

问题是,我可以高兴地调用一个服务(无论我先打电话作品),但是打电话,直到我IISRESET再试其他的失败。这样我就可以开心地在同一时间,直到处理回收通话双方只有一个。

我已经用尽了(或者我觉得我有)所有相关的Q&安培; A和文件,我能找到和他们都不来帮助我。 MSDN关于这些案件(这应该是faily常见)的文档的水平是令人震惊的,并没有什么作品,因为它似乎。

我用主机/ BaseAddresses / BaseAddress没有运气,每当我用它,我得到另一个错误(找不到HTTPS方案)。

我有一个名为安全的文件夹这是启用HTTPS里面IIS。

我有残疾MEX所以没有让我得到了通过previous错误的元数据。

任何人都得到了线索?我cluless ...

 <服务名称=Namespace.MyServicebehaviorConfiguration =MyBehaviour>
    <主机>
      < baseAddresses>
      < / baseAddresses>
    < /主机>
    <端点地址=HTTP://localhost/Services/MyService.svc/MyService
              NAME =则将MyService绑定=的wsHttpBinding
              bindingConfiguration =myWsHttpBinding合同=Namespace.IMyService/>    <端点地址=HTTPS://localhost/Services/Secure/MySslService.svc/MySslService
              NAME =MySslService绑定=basicHttpBinding的
              bindingConfiguration =MySslServiceBinding合同=Namespace.IMyService/>
  < /服务>

......

 <行为NAME =MyBehaviour>
      < CUSTOM1 />
      < CUSTOM2 />
      < serviceMetadata httpGetEnabled =FALSE/>
      < serviceDebug includeExceptionDetailInFaults =FALSE/>
      < serviceAuthorization principalPermissionMode =UseAspNetRolesroleProviderName =CustomProvider/>
      < serviceCredentials>
        < serviceCertificate findValue =一些storeLocation =LOCALMACHINESTORENAME =我x509FindType =FindBySubjectName/>        < userNameAuthentication userNamePasswordValidationMode =自定义customUserNamePasswordValidatorType =SomeClass的,SomeDll/>
      < / serviceCredentials>
    < /行为>

原来的错误是:


  

一个注册已经存在URI
  的http://本地主机/服务/ ....'。


  
  

说明:未处理的异常
  的执行过程中发生
  当前Web请求。请检查
  堆栈跟踪有关的详细信息
  该错误以及它起源于
  在code。


  
  

异常详细信息:
  System.InvalidOperationException:一
  注册已经存在URI
  的http://本地主机/服务/ ....'。


  
  

源错误:


  
  

生成了未处理的异常
  当前的执行过程中
  Web请求。关于信息
  例外的起源和地点
  可以使用异常被识别
  堆栈跟踪的下面。


  
  

堆栈跟踪:


  
  

[出现InvalidOperationException:一
  注册已经存在URI结果
  System.ServiceModel.Channels.Uri prefixTable 1.RegisterUri(URI
  URI,HostNameComparisonMode
  hostNameComparisonMode,TItem项)
  + 320 System.ServiceModel.Channels.HttpTransportManager.Register(TransportChannelListener
  channelListener)+380结果
  System.ServiceModel.Channels.TransportManager.Open(TransportChannelListener
  channelListener)816结果
  System.ServiceModel.Channels.TransportManagerContainer.Open(SelectTransportManagersCallback
  selectTransportManagerCallback)+121结果
  System.ServiceModel.Channels.HttpChannelListener.OnOpen(时间跨度
  超时)+125结果
  System.ServiceModel.Channels.CommunicationObject.Open(时间跨度
  超时)789结果
  System.ServiceModel.Channels.DatagramChannelDemuxer
2.OnOuterListenerOpen(ChannelDemuxerFilter
  过滤器,监听IChannelListener,
  时间跨度超时)606结果
  System.ServiceModel.Channels.SingletonChannelListener`3.OnOpen(时间跨度
  超时)+91结果
  System.ServiceModel.Channels.CommunicationObject.Open(时间跨度
  超时)789结果
  System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(时间跨度
  超时)+375


下面是WCF跟踪日志错误:


  

该ChannelDispatcher在
  的http://本地主机/服务/ ...'与
  合同(S)'IMyService'无法
  打开其IChannelListener。
  System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(时间跨度
  暂停)
  System.ServiceModel.Channels.CommunicationObject.Open(时间跨度
  暂停)
  System.ServiceModel.ServiceHostBase.OnOpen(时间跨度
  暂停)
  System.ServiceModel.Channels.CommunicationObject.Open(时间跨度
  暂停)
  System.ServiceModel.ServiceHostingEnvironment.HostingManager.ActivateService(字符串
  normalizedVirtualPath)
  System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(字符串
  normalizedVirtualPath)
  System.ServiceModel.ServiceHostingEnvironment.EnsureServiceAvailableFast(字符串
  relativeVirtualPath)
  System.ServiceModel.Activati​​on.HostedHtt prequestAsyncResult.HandleRequest()
  System.ServiceModel.Activati​​on.HostedHtt prequestAsyncResult.BeginRequest()
  System.ServiceModel.Activati​​on.HostedHtt prequestAsyncResult.OnBeginRequest(对象
  州)
  System.ServiceModel.AspNetPartialTrustHelpers.PartialTrustInvoke(ContextCallback
  回调,对象状态)
  System.ServiceModel.Activati​​on.HostedHtt prequestAsyncResult.OnBeginRequestWithFlow(对象
  州)
  System.Runtime.IOThreadScheduler.ScheduledOverlapped.IOCallback(UInt32的
  错误code,UInt32的的numBytes,
  NativeOverlapped * nativeOverlapped)
  System.Runtime.Fx.IOCompletionThunk.UnhandledExceptionFrame(UInt32的
  错误,UInt32的读取动作,
  NativeOverlapped * nativeOverlapped)
  System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32的
  错误code,UInt32的的numBytes,
  NativeOverlapped * pOVERLAP)



解决方案

OK,我固定我的问题。问题是我下的IM pression,我不得不在IIS中创建一个安全的文件夹,并把.svc文件在那里,以保证SSL传输。原来,这是不是这样的,所有我所要做的就是使用相同的.svc文件,只是定义了2端点:

 <端点地址=HTTP://localhost/Services/MyService.svc/MyService
          NAME =则将MyService绑定=的wsHttpBinding
          bindingConfiguration =myWsHttpBinding合同=Namespace.IMyService/><端点地址=HTTPS://localhost/Services/MyService.svc/MySecureService
          NAME =MySslService绑定=basicHttpBinding的
          bindingConfiguration =MySslServiceBinding合同=Namespace.IMyService/>

I am trying to host the same service inside the same website using two endpoints one HTTP and the other HTTPS.

The problem is I can happily call one service (whichever I call first works) but then call to the other fails until I iisreset and try again. SO I can happily call both but one at a time until a process recycle.

I have exhausted (or I think I have) all relevant Q&A and documents that I could find and none of them seem to help me. The level of documentation of MSDN regarding these cases (which should be faily common) is appalling and nothing works as it seems.

I have used Host/BaseAddresses/BaseAddress with no luck and whenever I used it, I get another error (cannot find an HTTPS scheme).

I have folder called Secure which is enabled for HTTPS inside IIS.

I have disabled mex so no metadata allowed which I got passed previous errors.

Anyone got a clue? I am 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>

Original error is:

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
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
2.OnOuterListenerOpen(ChannelDemuxerFilter filter, IChannelListener listener, TimeSpan timeout) +606
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

Here is the WCF Trace log error:

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)

解决方案

OK, I fixed my problem. The issue was I was under impression that I had to create a secure folder in IIS and put the .svc file in there to guarantee SSL transmission. It turned out that it is not the case and all I had to do was to use the same .svc file and just define 2 endpoints:

<endpoint address="http://localhost/Services/MyService.svc/MyService"
          name="MyService"   binding="wsHttpBinding"
          bindingConfiguration="myWsHttpBinding" contract="Namespace.IMyService" />

<endpoint address="https://localhost/Services/MyService.svc/MySecureService"
          name="MySslService"   binding="basicHttpBinding"
          bindingConfiguration="MySslServiceBinding" contract="Namespace.IMyService" />

这篇关于&QUOT;注册已存在的URI&QUOT;托管相同服务时,HTTPS和HTTP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆