使用http和https端点的Wcf

时间:2014-10-10 13:05:52

标签: c# .net wcf

我有一个自托管的WCF服务,并尝试将另一个端点用于https,仅用于测试环境。 我的app.config:

 <service name="service.Service1" behaviorConfiguration="ServiceBehaviour">

    <endpoint address="" binding="wsHttpBinding" bindingConfiguration="wsHttpBinding" contract="service.IService1"/>
    <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
  </service>
</services>

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

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


  <endpointBehaviors>
    <behavior name="web">
      <webHttp/>
    </behavior>
  </endpointBehaviors>


</behaviors>

使用这个app.config我得到异常“Could not find base address that matches scheme https”.但是我把基地址放在:

 <host>
      <baseAddresses>
        <add baseAddress="https://localhost:8090" />
          <add baseAddress="http://localhost:8099" />
      </baseAddresses>
    </host>
   <endpoint address="https://localhost:8090/secure" binding="wsHttpBinding" bindingConfiguration="wsHttpBinding" contract="service.IService1"/>
    <endpoint address="http://localhost:8099/notsecure" binding="wsHttpBinding" bindingConfiguration="wsHttpBinding" contract="service.IService1"/>
    <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>

然后我得到其他例外:The provided URI scheme 'http' is invalid; expected 'https'.

那我怎么能这样做?如果我尝试只使用一个基地址和一个端点,它可能是http或https正常工作。

感谢。

0 个答案:

没有答案