“A registration already exists for URI” when hosting same service for HTTPS and HTTP

后端 未结 2 1672
北海茫月
北海茫月 2021-02-09 07:58

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 (wh

相关标签:
2条回答
  • 2021-02-09 08:23

    It's possible the nested directories are confusing IIS - I have had this happen before although not in the WCF context. Try changing the endpoint addresses to:

    address="http://localhost/MyService"
    address="https://localhost/MySslService"
    

    Can you try hosting the application from a console app instead of IIS? I'm pretty certain IIS is causing your problem somehow but this might confirm it.

    If it's possible, I'd also try to isolate the problem by removing some of the configuration detail - eg bindingConfiguration and behaviorConfiguration.

    Obviously these are just debugging steps I'd perform (you may have already) to try and isolate the problem - sorry I haven't got a full answer.

    0 讨论(0)
  • 2021-02-09 08:33

    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" />
    
    0 讨论(0)
提交回复
热议问题