在webHttp WCF服务上设置传输级别安全性

在webHttp WCF服务上设置传输级别安全性,wcf,security,webhttp,Wcf,Security,Webhttp,我试图在webHttp绑定WCF服务上设置传输级安全性我当前的配置如下所示 <system.serviceModel> <client> <endpoint binding="webHttpBinding" bindingConfiguration="webHttp" contract="PrimeStreamInfoServices.IService1" name="Client" /> </client> <bindings

我试图在webHttp绑定WCF服务上设置传输级安全性我当前的配置如下所示

 <system.serviceModel>
<client>
  <endpoint binding="webHttpBinding" bindingConfiguration="webHttp"
    contract="PrimeStreamInfoServices.IService1" name="Client" />
</client>
<bindings>
<webHttpBinding>
  <binding name="webHttp" maxBufferPoolSize="1500000"  maxReceivedMessageSize="1500000"  maxBufferSize="1500000">
  <security mode="Transport">
      <transport clientCredentialType="None"

            proxyCredentialType="None"
            realm="string" />
  </security>
  </binding>

</webHttpBinding>
</bindings>
<services>

  <service name="PrimeStreamInfoServices.Service1" behaviorConfiguration="PrimeStreamInfoServices.Service1Behavior">
    <!-- Service Endpoints -->
    <endpoint address="" binding="webHttpBinding" bindingConfiguration="webHttp" contract="PrimeStreamInfoServices.IService1">
      <!-- 
          Upon deployment, the following identity element should be removed or replaced to reflect the 
          identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity 
          automatically.
      -->
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="PrimeStreamInfoServices.Service1Behavior">

      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
      <serviceMetadata httpGetEnabled="true"/>
      <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<diagnostics>

  <messageLogging logMalformedMessages="true"  logMessagesAtServiceLevel="true"
    logMessagesAtTransportLevel="true" />

</diagnostics>

但是,当我运行服务时,会出现异常: 找不到与绑定WebHttpBinding的终结点的方案https匹配的基址。注册的基址方案为[http]


我知道我遗漏了一些东西,我一直在尝试各种我无法理解的事情,有人知道我必须做什么吗?

是-使用合适的证书切换到HTTPS。在HTTP的情况下,传输安全由SSL通道提供。您不能在纯HTTPS上使用WS*传输安全性忽略我之前的回答,我认为wsHttpBinding不是webHttpBinding

您用来调用必须以https开头的服务的地址


您能否尝试添加一个基本地址(在您的服务配置的
元素中),即https?是否在代码中添加一个(或多个)基址

<service name="PrimeStreamInfoServices.Service1" 
         behaviorConfiguration="PrimeStreamInfoServices.Service1Behavior">
   <host>
      <baseAddresses>
         <add baseAddress="https://localhost:8080/YourService.svc" />
      </baseAddresses>
   </host>
   <!-- Service Endpoints -->
   <endpoint ......
</service>


请记住,除了正确的WCF配置之外,还需要配置IIS属性以在其上启用SSL(包括为SSL设置正确的X.509证书)。消息在传输过程中会对请求进行加密,这样就没有数据包嗅探器可以直接读取纯文本了吗?消息在发送之前会进行加密,因此,数据包嗅探器将无法查看内容。有关消息安全性的描述,请参见“无论如何,我不认为您可以为webHttp绑定执行消息”我在哪里指定我要HTTPs?