原文地址: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. 【赵渝强老师】搭建Hadoop环境

    说明:这里我们以本地模式和伪分布模式伪列,为大家介绍如何搭建Hadoop环境.有了这个基础,大家可以自行搭建Hadoop的全分布模式. 需要使用的安装介质: hadoop-2.7.3.tar.gz j ...

  2. C# 如何理解装箱和拆箱 ?

    装箱和拆箱就是C# 中数据类型的转换 : 装箱:值类型转换对象类型(引用类型,复杂类型) 拆箱:对象类型转换值类型 object obj=null; //引用类型 obj=1; //装箱 boxing ...

  3. amfe-flexible 包设置rem的基本值 vue 移动端适配方案

    下载 安装 :npm i -S amfe-flexible gw:GitHub - amfe/lib-flexible: 可伸缩布局方案 下载 2 个第三方包即可实现移动端适配 amfe-flexib ...

  4. find命令,查找文件

    find 是 Linux 中强大的搜索命令,不仅可以按照文件名搜索文件,还可以按照权限.大小.时间.inode 号等来搜索文件. [root@localhost ~]#find 搜索路径 [选项] 搜 ...

  5. 鲸鸿动能广告助力App流量高效变现,促进商业增长

    广告是App开发者实现流量变现的常用方法之一.当App积累了一定数量的用户后,开发者需要考虑如何有效地将流量转化为收入,以支持App的商业可持续增长. HarmonyOS SDK广告服务(Ads Ki ...

  6. 云原生周刊:2024 年 K8s 基准报告 | 2024.4.8

    开源项目推荐 Argo CD Image Updater Argo CD Image Updater 是一个自动更新 Argo CD 管理的 Kubernetes 工作负载容器镜像的工具.简而言之,它 ...

  7. KubeSphere 社区双周报 | OpenFunction v1.2.0 发布 | 2023.09.15-09.28

    KubeSphere 社区双周报主要整理展示新增的贡献者名单和证书.新增的讲师证书以及两周内提交过 commit 的贡献者,并对近期重要的 PR 进行解析,同时还包含了线上/线下活动和布道推广等一系列 ...

  8. HTB打靶记录-Infiltrator

    nmap scan nmap -A 10.10.11.31 Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-10-15 13:18 CST Nma ...

  9. Selenium实现元素定位

    Selenium提供了定位元素的方法find_element(),该方法被定义在WebDriver类中. 一.参数 1.两个参数,参数1根据不同定位方法确定,定位方法如下: (1)通过id定位:使用参 ...

  10. 基于Java+SpringBoot+Mysql实现的古诗词平台功能设计与实现十

    一.前言介绍: 1.1 项目摘要 随着信息技术的迅猛发展和数字化时代的到来,传统文化与现代科技的融合已成为一种趋势.古诗词作为中华民族的文化瑰宝,具有深厚的历史底蕴和独特的艺术魅力.然而,在现代社会中 ...