2009-07-27 121 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有關於如何做的一些體面的信息。