2009-07-27 90 views
0

我想在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> 

设置传输层安全性然而,当我跑我的服务我得到例外: 找不到匹配方案HTTPS与结合的WebHttpBinding端点的基址。注册的基地址方案是[http]。

我知道我在想念的东西,我一直在尝试各种事情我无法弄清楚,任何人有什么我必须做一些投入?

回答

0

是 - 切换到HTTPS,用合适的证书。对于HTTP,传输安全由SSL通道提供。你不能有WS *传输安全通过纯HTTPS

+0

我在哪里可以指定我想HTTPs的? – Daniel 2009-07-27 20:08:16

0

忽略我以前的答案,我想WsHttpBinding的不是的WebHttpBinding。

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

https://machineName/ServiceName

+0

在传输过程中,消息是否会对请求进行加密,因此没有数据包嗅探器可以读取纯文本? – Daniel 2009-07-27 20:06:53

0

你可以尝试添加基地址是HTTPS(服务配置的<host>元素中)?你是否在代码中添加(或多个)基地址?

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

不是100%确定,如果这与webHttpBinding一起工作,但试试!

马克

0

记住,除了正确的WCF的配置,你还需要配置IIS属性上启用SSL(包括设置SSL正确X.509证书)。 docs有关于如何做的一些体面的信息。