Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
转换;“HelloWorld”;WCF Web服务是否使用https?_Wcf_Web Services_Https - Fatal编程技术网

转换;“HelloWorld”;WCF Web服务是否使用https?

转换;“HelloWorld”;WCF Web服务是否使用https?,wcf,web-services,https,Wcf,Web Services,Https,如果你是一个初学者,那么很难找到web服务,这不是因为这个概念很难,不是因为它很难,而是因为这项技术经历了很多曲折,如果你得到的只是对实现略有不同的答案,那么谷歌搜索帮助也无济于事 [例如,我们的解决方案从来没有.svc文件或.asmx文件,尽管这些文件经常出现在答案中,而且我们的web.config没有任何行为或绑定元素,其他人似乎也没有] 我们使用了一个教程来设置我认为在IIS6上运行的“WCF Web服务”。很好用 但我们希望将其转换为使用加密/https 因此,我们选中了IIS中的“需要

如果你是一个初学者,那么很难找到web服务,这不是因为这个概念很难,不是因为它很难,而是因为这项技术经历了很多曲折,如果你得到的只是对实现略有不同的答案,那么谷歌搜索帮助也无济于事

[例如,我们的解决方案从来没有.svc文件或.asmx文件,尽管这些文件经常出现在答案中,而且我们的web.config没有任何
行为
绑定
元素,其他人似乎也没有]

我们使用了一个教程来设置我认为在IIS6上运行的“WCF Web服务”。很好用

但我们希望将其转换为使用加密/https

因此,我们选中了IIS中的“需要安全通道”框:

不确定还有什么要配置的,但是。。。不管怎样,继续。接下来我想我们必须修改我们的web.config文件。。。但是什么和如何呢?下面是我们在web.config中的
system.serviceModel
下得到的内容:

<system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"></serviceHostingEnvironment>
    <standardEndpoints>
        <webHttpEndpoint>
            <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"></standardEndpoint>
        </webHttpEndpoint>
    </standardEndpoints>
</system.serviceModel>


那么我们下一步需要做什么呢?

好的,不幸的是,如果没有所有的代码,很难做到规范性,但下面是概述:

您需要将这些绑定和行为添加到web.config中

我将从basicHttpBinding开始,让它像当前一样工作,但这次您将指定绑定细节,而不是使用默认值。要“关闭”https,请将bindingConfiguration中的安全模式更改为None

完成后,您的WCF服务将有如下内容:

<services>
    <service behaviorConfiguration="webServiceClientBehavior" name="My.Service.ServiceName">
            <endpoint address="http://localhost:5803/LSClient"  binding="basicHttpBinding" bindingConfiguration="secureBinding" contract="My.Service.IServiceName"/>
    </service>
</services>

对于bindingConfiguration:

<bindings>
      <basicHttpBinding>
        <binding name="secureBinding">
          <security mode="Transport" />
        </binding>
      </basicHttpBinding>
</bindings>
<serviceBehaviors>
       <behavior name="webServiceClientBehavior">
          <!--For MetaData-->
          <serviceMetadata httpGetEnabled="true" httpGetUrl="http://localhost:5802/LSClientMD"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
</serviceBehaviors>

对于行为配置:

<bindings>
      <basicHttpBinding>
        <binding name="secureBinding">
          <security mode="Transport" />
        </binding>
      </basicHttpBinding>
</bindings>
<serviceBehaviors>
       <behavior name="webServiceClientBehavior">
          <!--For MetaData-->
          <serviceMetadata httpGetEnabled="true" httpGetUrl="http://localhost:5802/LSClientMD"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
</serviceBehaviors>

这些将需要根据您的实现进行轻微调整,但这只是一个基本概述