提供的URIscheme“https”是无效的; 预期'http'。 参数名称:via

我正在尝试通过基于httpHttpBinding通过https使用WCF服务。 这是我的web.config:

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

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

提供的URIscheme“https”是无效的; 预期'http'。 参数名称:via

尝试在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> 

添加这个答案,就是因为你不能在评论中做很多花哨的格式。
我有同样的问题,除了我完全在代码中创build和绑定我的Web服务客户端。
原因是DLL被上传到系统中,这就禁止使用configuration文件。

这是代码,因为它需要更新通过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 dev服务器)上运行这个还是在安装了cert的IIS上运行? 过去,我曾经遇到过一些问题,希望在开发Web服务器上连接安全的端点。

这是过去为我工作的绑定configuration。 它使用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" /> 

此外,请确保您更改客户端configuration以启用传输安全性。

我有和OP一样的问题。 我的configuration和情况完全相同。 在Visual Studio的testing项目中创build服务引用并确认服务正在运行之后,我最终将其缩小为WCFStorm中的问题。 在Storm中,你需要点击“configuration”设置选项(而不是“客户端configuration”)。 点击后,点击popup的对话框中的“安全”选项卡。 确保“身份validationtypes”设置为“无”(默认为“Windows身份validation”)。 Presto,它的工作原理! 我总是在WCFStorm中testing我的方法,因为我正在构build它们,但从来没有尝试过使用它来连接到已经在SSL上设置的方法。 希望这可以帮助别人!

从更改

 <security mode="None"> 

 <security mode="Transport"> 

在你的web.config文件中。 此更改将允许您使用https而不是http

我在custom bindingscheme中遇到了同样的exception。 任何人使用这种方法,也可以检查这一点。

我实际上是从local WSDL文件添加服务引用。 它成功添加,并要求自定义绑定添加到configuration文件。 但是,实际的服务是https; 不是http。 所以我把httpTransport元素改为httpsTransport 。 这解决了这个问题

 <system.serviceModel> <bindings> <customBinding> <binding name="MyBindingConfig"> <textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16" messageVersion="Soap11" writeEncoding="utf-8"> <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> </textMessageEncoding> <!--Manually changed httpTransport to httpsTransport--> <httpsTransport manualAddressing="false" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" allowCookies="false" authenticationScheme="Anonymous" bypassProxyOnLocal="false" decompressionEnabled="true" hostNameComparisonMode="StrongWildcard" keepAliveEnabled="true" maxBufferSize="65536" proxyAuthenticationScheme="Anonymous" realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false" useDefaultWebProxy="true" /> </binding> </customBinding> </bindings> <client> <endpoint address="https://mainservices-certint.mycompany.com/Services/HRTest" binding="customBinding" bindingConfiguration="MyBindingConfig" contract="HRTest.TestWebserviceManagerImpl" name="TestWebserviceManagerImpl" /> </client> </system.serviceModel> 

参考

  1. WCF与http和https上的自定义绑定

跑到同样的问题,这是我的解决scheme在最后的结果:

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

我基本上用Httpsreplace每个Http。 如果您愿意,可以尝试添加两者。

它是一个很好的记住,configuration文件可以拆分辅助文件,使不同的服务器(开发/演示/生产等)更容易configuration,而无需重新编译代码/应用程序等。例如,我们使用它们,让现场工程师使端点更改而不实际触及“真实”文件。

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

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

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

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

  <bindings configSource="Bindings.config" /> 

在bindings.config文件中,我们切换基于协议的安全性

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

现在,工程师只需要改变Bindings.Config文件和Client.Config来存储每个端点的实际URL。

这样,我们可以将端点从http更改为https并再次返回以testing应用程序,而无需更改任何代码。

希望这可以帮助。

在OP中重新提出这个问题:

我正在使用WCFStorm连接[WCF服务],它能够正确地检索所有的元数据,但是当我调用实际的方法时,我会得到:

提供的URIscheme“https”是无效的; 预期'http'。 参数名称:via

WCFStorm教程在使用IIS和SSL时解决了这个问题。

他们的解决scheme为我工作:

  1. 要修复错误,请生成一个匹配wcf服务configuration的客户端configuration。 最简单的方法就是使用Visual Studio。

    • 打开Visual Studio并添加一个服务引用到服务。 VS将生成一个与服务匹配的app.config文件

    • 编辑app.config文件,使其可以被WCFStorm读取。 请参阅加载客户端App.config文件 。 确保endpoint / @ name和endpoint / @ contract属性与wcfstorm中的值匹配。

  2. 将已修改的app.config加载到WCFStorm [使用客户端configurationtoobarbutton]。

  3. 调用该方法。 这次方法调用将不再失败

项目(1)上一个项目符号意味着删除 VS预先添加到端点合同属性的名称空间前缀 ,默认情况下为“ServiceReference1”

 <endpoint ... contract="ServiceReference1.ListsService" ... /> 

所以在app.config中加载到您希望用于ListsService的WCFStorm中:

 <endpoint ... contract="ListsService" ... /> 

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

如果你以编程的方式进行,而不是在web.config中:

 new WebHttpBinding(WebHttpSecurityMode.Transport)