在为HTTPS和HTTP托管相同服务时,"已存在URI注册"

Ali*_*tad 7 iis https wcf binding http

我正在尝试使用两个端点一个HTTP和另一个HTTPS在同一网站内托管相同的服务.

问题是我可以愉快地调用一个服务(无论我称之为第一个工作),然后调用另一个服务失败,直到我iisreset并再次尝试.所以,我可以愉快地一次调用两个,直到一个进程回收.

我已经筋疲力尽(或者我认为我有)所有相关的问答和文件,我找不到,但似乎没有人帮助我.MSDN关于这些案例的文档级别(应该是常见的)是令人震惊的,并且看起来没有任何作用.

我没有运气使用Host/BaseAddresses/BaseAddress,每当我使用它时,我都会收到另一个错误(无法找到HTTPS方案).

我有一个名为Secure的文件夹,它在IIS中启用了HTTPS.

我已经禁用mex所以没有允许的元数据我已经通过了以前的错误.

有人知道吗?我很无聊......

  <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>
Run Code Online (Sandbox Code Playgroud)

.....

   <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>
Run Code Online (Sandbox Code Playgroud)

原始错误是:

已经存在URI'http:// localhost/Services/....'的注册.

描述:执行当前Web请求期间发生未处理的异常.请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息.

异常详细信息:System.InvalidOperationException:URI'http:// localhost/Services/....'已存在注册.

来源错误:

在执行当前Web请求期间生成了未处理的异常.可以使用下面的异常堆栈跟踪来识别有关异常的起源和位置的信息.

堆栈跟踪:

[InvalidOperationException:URI
System.ServiceModel.Channels.UriPrefixTable 已经存在注册2.OnOuterListenerOpen(ChannelDemuxerFilter过滤器,IChannelListener侦听器,TimeSpan超时)+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)+3751.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



这是WCF跟踪日志错误:

'http:// localhost/Services/...'中的ChannelDispatcher与合同'"IMyService"'无法打开其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.

Ali*_*tad 3

好的,我解决了我的问题。问题是我的印象是我必须在 IIS 中创建一个安全文件夹并将 .svc 文件放入其中以保证 SSL 传输。事实证明,情况并非如此,我所要做的就是使用相同的 .svc 文件并定义 2 个端点:

<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" />
Run Code Online (Sandbox Code Playgroud)