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
C# 在HTTPS上托管WCF Windows服务_C#_Wcf_Https - Fatal编程技术网

C# 在HTTPS上托管WCF Windows服务

C# 在HTTPS上托管WCF Windows服务,c#,wcf,https,C#,Wcf,Https,我正在尝试在https上配置使用windows服务托管的WCF服务 该服务可用于http,但似乎无法用于https 配置文件(适用于http): <?xml version="1.0" encoding="utf-8" ?> <configuration> <system.serviceModel> <serviceHostingEnvironment aspNetCompatibilityEnabl

我正在尝试在https上配置使用windows服务托管的WCF服务

该服务可用于http,但似乎无法用于https

配置文件(适用于http):

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <serviceHostingEnvironment  aspNetCompatibilityEnabled="false" />

    <!-- Set up Custom Behaviors -->
    <behaviors>
      <serviceBehaviors>
        <behavior name="CalculatorServiceBehavior">
          <serviceMetadata httpGetEnabled="true" httpsGetUrl="true" />
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>

    <!-- Set up the binding configuration  -->
    <bindings>
      <wsHttpBinding>
       <binding name="HttpsSOAPBinding">
          <security mode="Transport">
            <transport clientCredentialType="None"/>
          </security>
        </binding>
        <binding name="HttpSOAPBinding">
          <security mode="None" />
        </binding>
      </wsHttpBinding>
    </bindings>

    <services>
      <service name="Microsoft.ServiceModel.Samples.CalculatorService"
               behaviorConfiguration="CalculatorServiceBehavior">
        <host>
          <baseAddresses>
            <add baseAddress="http://server_name:8080/ServiceModelSamples/service"/>
          </baseAddresses>
        </host>
        <endpoint address=""
                  binding="wsHttpBinding"
                  bindingConfiguration="HttpSOAPBinding"
                  contract="Microsoft.ServiceModel.Samples.ICalculator" />
        <endpoint address="mex"
                  binding="mexHttpBinding"
                  contract="IMetadataExchange" />
      </service>
    </services>
    
  </system.serviceModel>
</configuration>

缺少什么吗?

因此您表示不确定端口是否打开。我将尝试使用telnet命令查看您的端口是否可以从您试图访问服务的机器上访问。为此,您需要在命令提示符中使用以下命令

telnet 192.168.1.1 8080
现在,您需要将192.168.1.1替换为您的服务器IP地址


另一件事,你可能想尝试找出你的问题是与防火墙或服务将登录到服务器本身,并试图击中你的服务在该服务器上本地


当然,这是假设您能够登录到服务器。

是否收到特定的错误消息?我还注意到,配置文件中的基址使用的是http协议,而不是https协议。在浏览URL时,我得到了“无法访问此站点”。我已经更新了基址,并将mex端点绑定更改为MEXHTTPSBindings您确定防火墙已打开,可以通过https攻击该服务器吗?好的,我不确定。我应该使用在服务器上工作的现有https端口吗?除了向端口添加证书外,我们还需要添加https的基址,有关它的更多信息,您可以参考此链接:谢谢Brandon。这是防火墙问题。它在防火墙上打开的端口443上工作。
telnet 192.168.1.1 8080