2011-03-17 128 views
0

我有一个silverlight客户端,目前与WCF服务不安全地通信。如何使WCF服务https启用并在Silverlight中使用它?

1>我想让WCF服务受到保护。(https启用) 2>我想在silverlight客户端中引用安全的wcf服务。

任何人都可以帮忙配置服务?

Web.config文件:

<serviceHostingEnvironment aspNetCompatibilityEnabled="true"></serviceHostingEnvironment> 

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

<services> 
    <service behaviorConfiguration="DataService.Service1Behavior" 
    name="DataService.Service1"> 
    <endpoint address="" binding="basicHttpBinding" bindingConfiguration="MyBasicHttpBinding" 
     contract="DataService.IService1">   
    </endpoint> 
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
    </service>  
</services> 

<behaviors> 
    <serviceBehaviors> 
    <behavior name="DataService.Service1Behavior"> 
     <serviceMetadata httpGetEnabled="true" /> 
     <serviceDebug includeExceptionDetailInFaults="true" httpHelpPageEnabled="true" httpsHelpPageEnabled="true" /> 
    </behavior>  
    </serviceBehaviors> 
</behaviors> 

我收到以下错误信息:

找不到与结合basicHttpBinding的匹配方案HTTPS端点的基址。注册的基地址方案是[http]。

回答

-2

尝试添加baseAddresses部分到服务元素:

<services>   
    <service behaviorConfiguration="DataService.Service1Behavior" 
    name="DataService.Service1"> 
    <host> 
     <baseAddresses> 
     <add baseAddress="https://[your url]"/> 
     <add baseAddress="http://[your url]"/> 
     </baseAddresses> 
    </host> 
    <endpoint address="" binding="basicHttpBinding" bindingConfiguration="MyBasicHttpBinding" 
     contract="DataService.IService1">   
    </endpoint> 
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
    </service>  
</services> 
+0

错误仍然存​​在配置WCF。 – RockWorld 2011-03-17 08:01:15

1

你需要正确的绑定和服务的行为,如下面的配置

1)在结合地方givn主要部分= “basicHttpBinding的” 使用绑定= “的wsHttpBinding ” 2)在结合=“ mexHttpBinding” 的地方使用绑定= “mexHttpsBinding” 3)在服务行为serviceMetadata httpsGetEnabled =“真”

你可以找到非常简单的步骤加入,即使主机基址,HTTPS后HTTPS here

+0

Silverlight是否支持wsHttpBinding? – RockWorld 2011-03-17 08:37:05

+0

你是对的我错过了你的问题silverlight部分,你可以尝试替代解决方案1)http://www.dotnetcurry.com/ShowArticle.aspx?ID=590或2)http://www.dotnetcurry.com/ ShowArticle.aspx?ID = 589 – 2011-03-17 10:17:10