HTTP Windows 服务到 HTTPS [英] HTTP Windows Service to HTTPS

查看:29
本文介绍了HTTP Windows 服务到 HTTPS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Windows 服务来托管我的 wcf 服务.

I have a windows service that hosts my wcf service.

app.config 是:

The app.config is:

    <?xml version="1.0" encoding="utf-8"?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/>
    </startup>

  <system.serviceModel>
    <services>
      <service behaviorConfiguration="RestWCFServiceLibrary.Service1Behavior" name="RestWCFServiceLibrary.RestWCFServiceLibrary">
        <endpoint address="" binding="webHttpBinding" contract="RestWCFServiceLibrary.IRestWCFServiceLibrary" behaviorConfiguration="web">
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8888/RestWCFServiceLibrary/"/>
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="RestWCFServiceLibrary.Service1Behavior">
          <serviceMetadata httpGetEnabled="True"/>
          <serviceDebug includeExceptionDetailInFaults="False"/>
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="web">
          <webHttp/>
        <CorsSupport/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
  <extensions>
            <behaviorExtensions>
                <add name="CorsSupport" type="WebHttpCors.CorsSupportBehaviorElement, WebHttpCors, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>
            </behaviorExtensions>
        </extensions>
  </system.serviceModel>

</configuration>

我的问题是,如果我的网站使用 https://,则由于 CORS 无法进行 http 调用.https 网站向本地主机发出 ajax GET 请求.

My problem is that if I have my website using https:// it fails to make the http call because of CORS. The https website makes an ajax GET request to the localhost.

现在我正在尝试将我的 Windows 服务更改为 https,但在任何地方我都看到了一些命令行 ssl 绑定.有没有其他方法可以更改我的 wcf 自托管 Windows 服务以使用 https?

Now I am trying to change my windows service to https but everywhere I see some command line ssl bindings. Is there a different way I can change my wcf self hosted windows service to use https?

我需要做什么才能将此 http 服务迁移到 https.

What do I need to do in order to get this http service migrated over to https.

请举例说明需要在我的 app.config 中修改的内容.

Please provide example of what needs to be modified in my app.config.

推荐答案

我偶然发现了类似的问题,所以我所做的是使用 WCF 配置工具为我和内部端点编写 App.Config 我选择了 mexhttpsbinding 和 yaa https 绑定工作..

I stumbled upon similar problem so what i did was used WCF Configuration tool to write a App.Config for me and inside endpoints I selected mexhttpsbinding and yaa the https binding worked..

这篇关于HTTP Windows 服务到 HTTPS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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