原文地址:https://weblogs.asp.net/srkirkland/wcf-bindings-needed-for-https

我刚刚完成了我的第一个 WCF 应用,它在我的开发机上顺利工作,直到我将它部署到产品环境下。所有的 WCF 服务突然都不工作了。我得到的是一个 javaScript 错误 TestService is not defined

当我深入查看 JS 服务引用的时候,我得到这样的一个错误:

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

所以,我的 WCF 服务将它自身注册为 HTTPS (因为它基于 SSL),但是我仅仅为 HTTP 配置了绑定。解决方案是在你的 web.config 中定义一个订制的支持 HTTPS 的 webHttpbinding 绑定,它的安全模式配置为 Transport。然后你需要在你的端点定义中使用 bindingConfiguration 指向你的订制绑定。

第一步,定义一个支持 HTTPS 的绑定,它的安全模式配置为传输层控制,绑定的名称为 webBinding

<bindings>
<webHttpBinding>
<binding name="webBinding">
<security mode="Transport">
</security>
</binding>
</webHttpBinding>
</bindings>

然后,在 service 上使用该绑定,

<service name="TestService">
<endpoint address="" behaviorConfiguration="TestServiceAspNetAjaxBehavior"
binding="webHttpBinding" bindingConfiguration="webBinding" contract="TestService" />
</service>

完整的支持 HTTPS 的 system.serviceModel 配置节如下所示:

<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="TestServiceAspNetAjaxBehavior">
<enableWebScript />
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<services>
<service name="TestService">
<endpoint address="" behaviorConfiguration="TestServiceAspNetAjaxBehavior"
binding="webHttpBinding" bindingConfiguration="webBinding" contract="TestService" />
</service>
</services>
<bindings>
<webHttpBinding>
<binding name="webBinding">
<security mode="Transport">
</security>
</binding>
</webHttpBinding>
</bindings>
</system.serviceModel>

希望能够帮助遇到类似问题的朋友。

WCF Bindings Needed For HTTPS的更多相关文章

  1. 通过配置web.config使WCF向外提供HTTPS的Restful Service

    如何通过WCF向外提供Restful的Service请看如下链接 http://www.cnblogs.com/mingmingruyuedlut/p/4223116.html 那么如何通过对web. ...

  2. 引用WCF地址报下载“https://xxx:8004/TerminalHandler.svc?disco”时出错问题

    服务发布了wcf服务后,在客户端引用发现出现以下错误 - 来自“DISCO 文档”的报告是“下载“https://servername:8004/TerminalHandler.svc?disco”时 ...

  3. WCF 客户端 BasicHttpBinding 兼容 HTTPS 和 HTTP

    背景:全站HTTPS的时代来了 全站HTTPS,请参考:http://www.cnblogs.com/bugly/p/5075909.html 1. 设置BasicHttpBinding的BasicH ...

  4. WCF自寄宿实现Https绑定

    一.WCF配置 1 Address 将服务端发布地址和客户端访问地址都配置为https开始的安全地址.参考如下. <add key="SrvUrl" value=" ...

  5. WCF bindings comparison z

    Binding Protocol/Transport Message Encoding Security Default Session Transaction Duplex BasicHttpBin ...

  6. WCF发布到IIS 7.0,并以https访问

    一.IIS 7.0中如何生成服务器证书,并要求网站以http访问可参考: http://www.cnblogs.com/chnking/archive/2008/10/07/1305811.html ...

  7. WCF basicHttpBinding之Transport Security Mode, clientCredentialType="None"

    原创地址:http://www.cnblogs.com/jfzhu/p/4071342.html 转载请注明出处 前面文章介绍了<WCF basicHttpBinding之Message Sec ...

  8. WCF学习系列三--【WCF Interview Questions – Part 3 翻译系列】

    http://www.topwcftutorials.net/2012/10/wcf-faqs-part3.html WCF Interview Questions – Part 3 This WCF ...

  9. WCF系列(六) - WCF安全系列(一) - basicHttpBinding

    绑定可指定在与终结点通话时所使用的通信机制,并指示如何连接到终结点.绑定由一些元素组成,这些元素指定如何对 Windows Communication Foundation (WCF) 通道进行分层以 ...

  10. Adapter as a WCF Binding - In Depth

    WCF LOB Adapter SDK surfaces an adapter as a custom WCF Binding.  A WCF Bindingcorresponds to the “H ...

随机推荐

  1. Winrar 免广告、去评估版的解决办法 ( 实测有效 )

    事件起因: 在打开 Winrar 压缩软件的时候,总是会弹出广告弹窗,而且上面还是显示评估版本. 解决办法: 1. 正常安装 Winrar 软件 2. 安装破解软件--Restorator http: ...

  2. 简单粗暴的实现 Blazor Server 登录鉴权

    既然是简单粗暴,那么就不用关心诸如 IDentityServer4,OAuth 之类的组件,也不使用 AuthenticationStateProvider.IAuthService, razor 页 ...

  3. USB2.0设备的休眠挂起及远程唤醒

    USB可见设备状态,分为连接(Attached),上电(Powered),默认(Default),地址(Address),配置(Configured)和挂起(Suspended)6个状态.所谓可见,即 ...

  4. Java日期时间API系列27-----Jdk8中java.time包中的新的日期时间API类,使用xk-time工具类创建日历应用,自定义节假日,工作日和打印日历表。

    1.日历相关类 1.1 日历类 CalendarWrapper package com.xkzhangsan.time.calendar; import java.io.Serializable; i ...

  5. 使用Redis的好处

    性能极高--redis能支持超过100K+每秒的读写频率 丰富的数据类型--Redis支持二进制案例的 Strings, Lists, Hashes, Sets 及 Ordered Sets 数据类型 ...

  6. 「模拟赛」多校 A 层联训 5

    A.好数(number) 很签,打完之后"不是这题我能做一个小时??" 对于每个数,都把它与前面的所有数的加和求一遍存进桶里,再遇到一个新数 \(a_i\) 时,枚举前面的所有 \ ...

  7. CSP-J2/S2 2023 游记

    可能早就应该发出来的游记. 2023-10-07 16:32. 前一天睡得比较晚,所以迟到了一点点. 上来先敲了个对拍,拍了一个 if a % 1000 = 0 then a++ 的 A + B,拍出 ...

  8. NetCore项目发布对前端项目进行打包合并发布

    在某个小项目中, api使用asp.net core 3.x 编写, UI页面则使用Vuejs. 正常情况下, 项目右键的发布只会发布api项目,而不会管Vuejs的项目. 所以通过简单的改造,在发布 ...

  9. python多线程应用-批量下载视频课程(宠医堂)

    #!/usr/bin/env python # -*- coding: UTF-8 -*- ''' @Name: cyt_record_download @IDE:PyCharm @Author:qt ...

  10. manim边学边做--极坐标平面

    PolarPlane,顾名思义,是用于创建极坐标平面的类. 与笛卡尔坐标系不同,极坐标系是基于角度和半径来定位点的,这里的每个点由一个角度和距离原点的距离表示. 在Manim中,PolarPlane通 ...