添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

一、IIS配置

  1. 保证IIS拥有配置https的功能
    在windows 功能中将IIS的所有功能开启即可。

  2. 生成证书 (标准企业需去平台申请证书,本文介绍开发自设置) 在这里插入图片描述

    在这里插入图片描述
    在这里插入图片描述

  3. 添加网站
    在这里插入图片描述

  4. 测试
    用IE打开,google等浏览器会直接打不开。 在这里插入图片描述

二、配置文件修改

  1. WebService Config

    1.endingpoint 配置:
    	源数据交换: mexHttpBinding -> mexHttpsBinding
    	否则报错:
    		找不到具有绑定 MetadataExchangeHttpBinding 的终结点的与方案 http 匹配的基址。注册的基址方案是 [https]...
    2.binding
    	1) wsHttpBinding 配置
    		<security mode="Message" >    -> 	<security mode="Transport" >
    		否则报错:
    			WCF问题:找不到具有绑定 WSHttpBinding 的终结点的与方案 http 匹配的基址。注册的基址方案是 [https]"错误
    	2) httpTransport -> httpsTransport
    3.Behavior
     <serviceMetadata httpGetEnabled="true" /> -> <serviceMetadata httpsGetEnabled="true" />
    
  2. Client Config

    1.binding配置:
    	1) <security mode="Message" >    -> 	<security mode="Transport" >
    	2) httpTransport -> httpsTransport
    

    3.注意点

    要保证客户端和服务端的 mode 类型一直,否则会报如下错误。
    The content type text/html of the response message does not match the content type of the binding (application/x-gzip). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were:
    

    三、查看wcf服务

    忽略证书即正常出结果。在这里插入图片描述

    四、客户端连接wcf服务

    1. 可能出现的问题
      Could not establish trust relationship for the SSL/TLS secure channel with authority.
      在client连接wcf创建通道的代码前增加如下代码即可:

      ServicePointManager.ServerCertificateValidationCallback += (s, cert, chain, sslPolicyErrors) => true;
      ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
      IClientChannel channel = GetChannelFactory(endPoint).CreateChannel() as IClientChannel;  //创建通道代码
      
    2. 解决完上面的问题即可正常连接登录

    本节开始的实例采用IIS作为WCF宿主,使用的契约和实现和前面使用的仍然相同,下面我们构建两个站点,一个WCF服务宿主站点,一个服务测试站点。首先我们创建服务端,打开vs2010à文件à新建项目à选择WCF模板àWCF服务应用程序,如图11-31。 图11-31 创建WCF如无应用程序 删除默认添加的SVC文件和接口文件,添加接口文件IHelloService.cs和接口实现文件Hel...
    昨天需要把做好的一个wcf服务发布到服务器站点下的一个虚拟目录中发布过程遇到了一个问题:服务器上的环境是https,因此需要多对配置文件修改于是在网上找啊找,遇到一个问题找一个问题,可是问题依然没解决。我在网上找到了一篇文章一步步照着上面写的做。 http://www.codeproject.com/KB/WCF/7stepsWCF.aspxhttp://www.codeproject.com/...
    介绍和目标步骤1:使用WCF项目创建一个简单的服务步骤2:在服务的web.config文件中启用传输级安全性步骤3:绑定绑定并指定HTTPS配置步骤4:启用Web应用程序HTTPS步骤5:在Web应用程序中使用服务步骤6:禁止HTTPS错误步骤7:享受成功源代码 介绍和目标 当我们谈论WCF安全性时,有两种方式:传输级安全性和消息级安全性。传输级安
      关于WCF开发的服务,如果使用IIS发布部署的,对于Web.Config文件中的配置还是相对严格,如果客户端和服务端的配置不一致就会出现莫名其妙的问题,让人及其头疼,所以要对WCF的配置设置非常熟悉。 View Code &lt;system.serviceModel&gt; &lt;bindings&gt; &lt;basicHttpBinding&gt; ...
    WCF 发布,本机正常,服务器报错,信息如下: ServiceMetadataBehavior 的 HttpsGetEnabled 属性设置为 True,而 HttpsGetUrl 属性是相对地址,但没有 https 基址。请提供 https 基址或将 HttpsGetUrl 设置为绝对地址。 说明: 执行当前 Web 请求期间,出现未经处理的异常。请检查堆