Wcf Http 和 Https

发布于 2024-10-16 08:20:07 字数 1880 浏览 1 评论 0原文

请帮忙!!

我的以下设置完美运行:-

  1. 本地 IIS 7 上的网站中托管的 WCF 服务库

  2. 本地网站上的 Silverlight 应用程序使用上述服务的 IIS 7

    使用

我正在编写的解决方案是用于 Intranet 而不是 Internet 使用,但是我的老板告诉我它需要通过 HTTPS 。我正在使用 Windows 身份验证。

以下是其中一个服务端点的配置文件的一部分(已更改以删除公司信息等):-

<services>
  <service behaviorConfiguration="stdHttpBehavior" name="WcfServiceLibrary.StaticDataService">
    <endpoint address="" binding="basicHttpBinding" bindingConfiguration="windowsHttpBinding"
      name="StaticDataService" contract="WcfServiceLibrary.ServiceContracts.IStaticDataService" />
    <endpoint address="mex" binding="mexHttpBinding" name="" contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost/WcfServiceLibrary/StaticDataService/" />
      </baseAddresses>
    </host>
  </service>

<behaviors>
  <serviceBehaviors>
    <behavior name="stdHttpBehavior">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
      <dataContractSerializer maxItemsInObjectGraph="2147483647" />
    </behavior>
  </serviceBehaviors>
</behaviors>

为了试验 Https,我创建了一个“自签名证书”。然后,我将 https 添加到默认网站绑定,并将这两个网站更改为需要 SSL,还更改了配置文件中的相关 URI。我设法让它工作,但现在我想回到标准 Http 并以该模式完成项目,因为它更容易使用。我把所有设置改回来了(并且我已经非常仔细地检查了这些设置)。

现在,如果我尝试下载 Silverlight 项目中的服务定义,我会收到此错误: -

'无法找到与绑定 BasicHttpBinding 的端点的方案 https 相匹配的基地址。注册的基地址方案是[http]。

如果我把证书放回IIS中并绑定。服务定义似乎下载正常,但它引用了 https URI,因此实际的服务调用都不起作用,因为它们是 http 地址!

我尝试添加一个新网站来托管该服务,但遇到了相同的错误。

过去几天我一直在尝试解决这个问题,但找不到答案。似乎在某个地方有一个隐藏的引用,而不是在我的项目中,因为它继续添加到 IIS 中的新网站。

Help please!!

I had the following set up working perfectly:-

  1. WCF Service Library hosted in web site on local IIS 7

  2. Silverlight Application on a web site on local IIS 7 using above services

The solution I am writing is for intranet and not internet use, however I have been told by my bosses that it needs to be over Https. I am using Windows Authentication.

Below is a chunk of the config file for one of the service endpoints (changed to remove company info etc):-

<services>
  <service behaviorConfiguration="stdHttpBehavior" name="WcfServiceLibrary.StaticDataService">
    <endpoint address="" binding="basicHttpBinding" bindingConfiguration="windowsHttpBinding"
      name="StaticDataService" contract="WcfServiceLibrary.ServiceContracts.IStaticDataService" />
    <endpoint address="mex" binding="mexHttpBinding" name="" contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost/WcfServiceLibrary/StaticDataService/" />
      </baseAddresses>
    </host>
  </service>

<behaviors>
  <serviceBehaviors>
    <behavior name="stdHttpBehavior">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
      <dataContractSerializer maxItemsInObjectGraph="2147483647" />
    </behavior>
  </serviceBehaviors>
</behaviors>

To experiment with Https I created a 'Self-Signed Certificate'. I then added https to the Default Web Site bindings and changed the two web sites to require SSL and also changed the relvant URIs in the config files. I managed to get this to work but now I want to go back to standard Http and finish the project in that mode as it was easier to work with. I changed all the settings back (and I have checked these extremely carefully).

Now I get this error if I try to downoad the Service definition in the Silverlight project: -

'Could not find a base address that matches scheme https for the endpoint with binding BasicHttpBinding. Registered base address schemes are [http].'

If I put back the certificate and binding in IIS. The Service definition appears to download OK, however it references an https URI and therefore none of the actual service calls work as they are http adresses!

I tried adding a new web site to host the service but got the same errors.

I have been trying to solve this for the last couple of days but cannot find an answer. It seems as though there is a hidden reference somewhere and not in my project as it continued with a new web site added to IIS.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

何必那么矫情 2024-10-23 08:20:07

要在基本 HTTP 绑定下使用 SSL over HTTP,您需要将终端节点切换为使用传输级安全性。在您的情况下,您还需要指示客户端凭据类型:

<bindings>
  <basicHttpBinding>
    <binding name="windowsHttpBinding">
      <security mode="Transport">
        <transport clientCredentialType="Windows" />
        <message />
      </security>
     </binding>
  </basicHttpBinding>
</bindings>

To use SSL over HTTP under Basic HTTP binding, you need to switch your endpoint to use Transport-level security. In your case you will also want to indicate the client credential type:

<bindings>
  <basicHttpBinding>
    <binding name="windowsHttpBinding">
      <security mode="Transport">
        <transport clientCredentialType="Windows" />
        <message />
      </security>
     </binding>
  </basicHttpBinding>
</bindings>
伪心 2024-10-23 08:20:07

这看起来似乎很明显,但是您是否将 windowsHttpBinding 绑定配置上的安全模式更改为 BasicHttpSecurityMode.None

<bindings>
  <basicHttpBinding>
    <binding name="windowsHttpBinding">
      <security mode="None" />
     </binding>
  </basicHttpBinding>
</bindings>

相关资源:

It may seem obvious, but did you change the security mode on the windowsHttpBinding binding configuration to BasicHttpSecurityMode.None?

<bindings>
  <basicHttpBinding>
    <binding name="windowsHttpBinding">
      <security mode="None" />
     </binding>
  </basicHttpBinding>
</bindings>

Related resources:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文