【问题标题】:How to make WCF service https enabled and consume it in silverlight?如何启用 WCF 服务 https 并在 silverlight 中使用它?
【发布时间】:2011-03-17 07:30:47
【问题描述】:

我有一个 silverlight 客户端,它当前与 WCF 服务进行不安全的通信。

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]。

【问题讨论】:

    标签: silverlight wcf httpservice


    【解决方案1】:

    您需要纠正的主要部分是以下配置中给出的绑定和服务行为

    1) 在 binding="basicHttpBinding" 的地方使用 binding="wsHttpBinding" 2) 在 binding="mexHttpBinding" 的地方使用 binding="mexHttpsBinding" 3)在服务行为serviceMetadata httpsGetEnabled="true"

    您可以在 https here 上找到配置 WCF 的非常简单的步骤

    【讨论】:

    【解决方案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>
    

    【讨论】:

    • 即使将主机基地址添加为 https,错误仍然存​​在。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-25
    • 2023-04-10
    • 2015-05-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多