如何通过SSL运行WCF服务?

Egg*_*ggo 7 c# ssl https wcf web-services

我正在IIS6中运行C#Web服务并尝试通过SSL工作.在执行tcpdump时,它会将初始呼叫显示为https,但是通过http显示每个其他呼叫.我的SSL证书是自签名的,https在我的Web浏览器中工作正常.我正在为客户端使用PHP SoapClient.

有谁知道会导致什么?

在wsdl中,地址位置设置为http.这应该是https吗?我该如何改变它?

<wsdl:service name="Service">
<wsdl:port name="BasicHttpBinding_Service" binding="i0:BasicHttpBinding_Service">
<soap:address location="http://example.com/Service.svc"/>
</wsdl:port>
</wsdl:service>
Run Code Online (Sandbox Code Playgroud)

Lad*_*nka 10

您必须将服务配置为使用HTTPS:

<bindings>
  <basicHttpBinding>
    <binding name="https">
      <security mode="Transport" />
    </binding>
  </basicHttpBinding>
</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior name="metadata">
      <serviceMetadata httpsGetEnabled="true" />  
    </behavior>
  </serviceBehaviors>
</behaviors>
<services>
  <service name="..." behaviorConfiguration="metadata">
    <endpoint address="..." contract="..." binding="basicHttpBinding"
              bindingConfiguration="https" />
  </service>
</services>
Run Code Online (Sandbox Code Playgroud)

这将允许仅通过HTTPS调用您的服务,因为没有暴露不安全的端点.WSDL也只能通过HTTPS访问,因为未启用HTTP GET.