当前位置: 代码迷 >> Web Service >> wcf经过https访问
  详细解决方案

wcf经过https访问

热度:319   发布时间:2016-05-02 02:42:52.0
wcf通过https访问
大家可以参考http://www.cnblogs.com/frank_xl/archive/2009/08/13/1543848.html
爲什麽我在添加服务引用的時候在輸入https://localhost:9001/Service1后,提示的錯誤是:下载“https://localhost:9001/Service1”时出错。
无法连接到远程服务器
由于目标机器积极拒绝,无法连接。 127.0.0.1:9001
元数据包含无法解析的引用:“https://localhost:9001/Service1”。
无法连接到 https://localhost:9001/Service1。TCP 错误代码 10061: 由于目标机器积极拒绝,无法连接。 127.0.0.1:9001。 
无法连接到远程服务器
由于目标机器积极拒绝,无法连接。 127.0.0.1:9001
如果该服务已在当前解决方案中定义,请尝试生成该解决方案,然后再次添加服务引用。

证书这块我应该弄好了我可以用httpcfg query ssl查看:

 IP                      : 127.0.0.1:9001
 Hash                    : 719c6cac58dfb5 d3d 0d9a5355abf954e972e27
 Guid                    : {00000000-0000-0000-0000-000000000000}
 CertStoreName           : (null)
 CertCheckMode           : 0
 RevocationFreshnessTime : 0
 UrlRetrievalTimeout     : 0
 SslCtlIdentifier        : (null)
 SslCtlStoreName         : (null)
 Flags                   : 0

这里有个问题Hash是不是就是证书的微缩图,在证书的详细信息里能够查看,还是就是怎么把HTTPS HOST 到 IIS?
我的app.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.web>
    <compilation debug="true" />
  </system.web>
  <!-- 部署服务库项目时,必须将配置文件的内容添加到 
  主机的 app.config 文件中。System.Configuration 不支持库的配置文件。-->
  <system.serviceModel>
    <services>
      <service name="WcfServiceLibrary.Service1" behaviorConfiguration="WcfServiceLibrary.Service1Behavior">
        <host>
          <baseAddresses>
            <add baseAddress = "https://localhost:9001" />
          </baseAddresses>
        </host>
        <!-- Service Endpoints -->
        <!-- 除非完全限定,否则地址将与上面提供的基址相关 -->
        <endpoint address ="Service1" binding="wsHttpBinding" contract="WcfServiceLibrary.IService1" bindingConfiguration="WcfServiceLibrary.Service1Binding" />
        
        <!-- Metadata Endpoints -->
        <!-- 元数据交换终结点由服务用于向客户端做自我描述。--> 
        <!-- 此终结点不使用安全绑定,应在部署前确保其安全或将其删除-->
        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
      </service>
    </services>
  相关解决方案