我试图使一个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”。参数 名称:通过


当前回答

改变 从

<security mode="None">

to

<security mode="Transport">

在你的网里。配置文件。此更改将允许您使用https而不是http

其他回答

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

I had the EXACT same issue as the OP. My configuration and situation were identical. I finally narrowed it down to being an issue in WCFStorm after creating a service reference in a test project in Visual Studio and confirming that the service was working. In Storm you need to click on the "Config" settings option (NOT THE "Client Config"). After clicking on that, click on the "Security" tab on the dialog that pops up. Make sure "Authentication Type" is set to "None" (The default is "Windows Authentication"). Presto, it works! I always test out my methods in WCFStorm as I'm building them out, but have never tried using it to connect to one that has already been set up on SSL. Hope this helps someone!

添加这个作为答案,因为你不能在注释中做太多花哨的格式。 我也遇到了同样的问题,只不过我完全用代码创建和绑定了我的web服务客户端。 原因是DLL被上传到一个系统,这禁止使用配置文件。

下面是代码,因为它需要更新以通过SSL通信…

Public Function GetWebserviceClient() As WebWorker.workerSoapClient
    Dim binding = New BasicHttpBinding()
    binding.Name = "WebWorkerSoap"
    binding.CloseTimeout = TimeSpan.FromMinutes(1)
    binding.OpenTimeout = TimeSpan.FromMinutes(1)
    binding.ReceiveTimeout = TimeSpan.FromMinutes(10)
    binding.SendTimeout = TimeSpan.FromMinutes(1)

    '// HERE'S THE IMPORTANT BIT FOR SSL
    binding.Security.Mode = BasicHttpSecurityMode.Transport

    Dim endpoint = New EndpointAddress("https://myurl/worker.asmx")

    Return New WebWorker.workerSoapClient(binding, endpoint)
End Function

您是在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" />

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

遇到同样的问题,这是我最后的解决方案:

        <basicHttpsBinding>
            <binding name="VerificationServicesPasswordBinding">
              <security mode="Transport">
              </security>
            </binding>
            <binding name="VerificationServicesPasswordBinding1" />
        </basicHttpsBinding>

我基本上把所有出现的Http都换成了Https。如果你愿意,你可以试着把它们都加起来。