C# HTTP和HTTPS端点在WCF中不工作

C# HTTP和HTTPS端点在WCF中不工作,c#,wcf,C#,Wcf,我无法在我的WCF服务中添加HTTP端点。WCF托管在Windows服务应用程序中。实际上,我的app.config是这样的: <system.serviceModel> <services> <service name="Test.Service" behaviorConfiguration="ServiceBehavior"> <host> <baseAddresses> <add

我无法在我的WCF服务中添加HTTP端点。WCF托管在Windows服务应用程序中。实际上,我的app.config是这样的:

<system.serviceModel>

<services>
  <service name="Test.Service" behaviorConfiguration="ServiceBehavior">

    <host>
      <baseAddresses>
        <add baseAddress="https://localhost:8090" />
        <add baseAddress="http://localhost:8099" />
      </baseAddresses>
    </host>

    <endpoint binding="wsHttpBinding" bindingConfiguration="httpBinding" contract="Test.IService"/>
    <endpoint binding="wsHttpBinding" bindingConfiguration="httpsBinding" contract="Test.IService"/>
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
    <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>


  </service>
</services>

<bindings>
  <wsHttpBinding>
    <binding name="httpsBinding">
      <security mode="Transport">
        <transport clientCredentialType="None" />
      </security>
    </binding>

    <binding name="httpBinding">
      <security mode="None"/>
    </binding>
  </wsHttpBinding>
</bindings>

<behaviors>
  <serviceBehaviors>
    <behavior name="ServiceBehavior">
      <serviceMetadata httpsGetEnabled="true" httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
      <serviceCredentials>
        <serviceCertificate
          storeLocation="LocalMachine"
          storeName="My"
          x509FindType="FindBySubjectName"
          findValue="server"/>
      </serviceCredentials>
    </behavior>
  </serviceBehaviors>


  <endpointBehaviors>
    <behavior name="web">
      <webHttp/>
    </behavior>
  </endpointBehaviors>
</behaviors>
如何在app.config中正确添加另一个端点

编辑:启动服务的代码:

 public class HostService
 {
     public static void Main( string[] args )
     {
        var host = new ServiceHost(typeof(Test.Service));
        host.Open();
        console.writeline("service starts");
        console.Readkey();
        host.Close();
     }
  }

不知道您所说的服务启动是什么意思,也不知道我何时尝试访问http或https url。给我们看看你的客户代码。或者你的意思是当试图查看元数据帮助页时?@ErikFunkenbusch服务启动时,我的意思是OnStart方法执行正常,没有异常,但当我尝试在两个URL上执行Get时,浏览器会显示该异常。是的,当我试图查看元数据帮助页面时,NullReferenceException来自试图访问尚未初始化的实例变量的代码。您没有显示任何代码;所以,真的很难猜出这可能是什么。你在用这个吗?如果你不喜欢,我强烈推荐。@PeterRitchie基本上是代码编辑op;
 public class HostService
 {
     public static void Main( string[] args )
     {
        var host = new ServiceHost(typeof(Test.Service));
        host.Open();
        console.writeline("service starts");
        console.Readkey();
        host.Close();
     }
  }