我试图使一个WCF服务在basicHttpBinding上使用https。这是我的web.config:

<!-- language: xml -->
<service behaviorConfiguration="MyServices.PingResultServiceBehavior"
         name="MyServices.PingResultService">
    <endpoint address="" 
              binding="basicHttpBinding" 
              bindingConfiguration="defaultBasicHttpBinding"
              contract="MyServices.IPingResultService">
        <identity>
            <dns value="localhost" />
        </identity>
    </endpoint>
    <endpoint address="mex" 
              binding="mexHttpBinding" 
              contract="IMetadataExchange" />
</service>
...
<bindings>
  <basicHttpBinding>
    <binding name="defaultBasicHttpBinding">
      <security mode="Transport">
        <transport clientCredentialType="None"/>
      </security>
    </binding>
  </basicHttpBinding>
</bindings>
...
<behaviors>
  <serviceBehaviors>
    <behavior name="MyServices.UpdateServiceBehavior">
      <serviceMetadata httpsGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>

我使用WCFStorm连接,它能够正确检索所有元数据,但当我调用实际的方法时,我得到:

提供的URI方案'https'无效;预计“http”。参数 名称:通过


当前回答

wsHttpBinding是一个问题,因为silverlight不支持它!

其他回答

您是在Cassini (vs开发服务器)上运行此程序,还是在安装了证书的IIS上运行此程序?我在过去尝试连接开发web服务器上的安全端点时遇到过问题。

下面是过去对我有用的绑定配置。它使用wsHttpBinding而不是basicHttpBinding。我不知道这对你来说是不是问题。

<!-- Binding settings for HTTPS endpoint -->
<binding name="WsSecured">
    <security mode="Transport">
        <transport clientCredentialType="None" />
        <message clientCredentialType="None"
            negotiateServiceCredential="false"
            establishSecurityContext="false" />
    </security>
</binding>

还有端点

<endpoint address="..." binding="wsHttpBinding"
    bindingConfiguration="WsSecured" contract="IYourContract" />

另外,请确保更改客户端配置以启用传输安全性。

<!-- Binding settings for HTTPS endpoint -->
<binding name="yourServiceName">
    <security mode="Transport">
        <transport clientCredentialType="None" />
        <!-- Don't use message -->
    </security>
</binding>

需要记住的是,配置文件可以拆分到次要文件中,以便在不同的服务器(开发/演示/生产等)上更容易地更改配置,而不必重新编译代码/应用程序等。 例如,我们使用它们允许现场工程师在不实际接触“真实”文件的情况下进行端点更改。

第一步是将绑定部分从WPF App.Config移出到它自己的单独文件中。

行为部分被设置为允许http和https(如果两者都被允许,似乎对应用程序没有影响)

<serviceMetadata httpsGetEnabled="true" httpGetEnabled="true" />

我们把绑定部分移到它自己的文件中;

 <bindings configSource="Bindings.config" /> 

在绑定中。配置文件基于协议进行安全切换

  <!-- None = http:// -->
  <!-- Transport = https:// -->
  <security mode="None" >

现在现场工程师只需要更改绑定。配置文件和客户端。配置中存储每个端点的实际URL。

通过这种方式,我们可以将端点从http更改为https,然后再返回来测试应用程序,而无需更改任何代码。

希望这能有所帮助。

我需要以下绑定来让我的工作:

        <binding name="SI_PurchaseRequisition_ISBindingSSL">
          <security mode="Transport">
            <transport clientCredentialType="Basic" proxyCredentialType="None" realm="" />
          </security>
        </binding>

尝试在app.config中添加消息凭据,如下所示:

<bindings> 
<basicHttpBinding> 
<binding name="defaultBasicHttpBinding"> 
  <security mode="Transport"> 
    <transport clientCredentialType="None" proxyCredentialType="None" realm=""/> 
    <message clientCredentialType="Certificate" algorithmSuite="Default" />
  </security> 
</binding> 
</basicHttpBinding> 
</bindings>