提供的URI方案'https:// '是无效的;预计& # 39;http # 39;。参数名称:via

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

429593 次浏览

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

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

<!-- 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" />

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

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

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

我遇到了和操作人员完全相同的问题。我的配置和情况完全相同。在Visual Studio的测试项目中创建了一个服务引用并确认该服务正在工作后,我最终将其缩小为WCFStorm中的一个问题。在Storm中,你需要点击“配置”设置选项(不是“客户端配置”)。点击之后,点击弹出对话框中的“Security”选项卡。确保“Authentication Type”设置为“None”(默认为“Windows Authentication”)。很快,它就起作用了!我总是在WCFStorm中测试我的方法,因为我正在构建它们,但从来没有尝试使用它来连接到一个已经在SSL上设置好的方法。希望这能帮助到一些人!

我在custom binding场景中有相同的异常。任何使用这种方法的人,也可以检查这个。

我实际上是从local WSDL文件中添加服务引用。它被成功添加,所需的自定义绑定被添加到配置文件。然而,实际的服务是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

重新概括一下OP中的问题:

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

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

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

他们的解决方案对我很有效:

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

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

    • 编辑app.config文件,以便WCFStorm可以读取它。请参见Loading Client App.config files. config文件。确保endpoint/@name和endpoint/@contract属性与wcfstorm中的值匹配。

    • 李< / ul > < / >
    • 加载修改后的app.config到WCFStorm[使用客户端配置toobar按钮]。

    • 调用该方法。这一次,方法调用将不再失败

第(1)项的最后一个项目实际上是指VS加在端点契约属性前的删除名称空间前缀,默认情况下为“ServiceReference1”

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

所以在你加载到WCFStorm的app.config中,你想为ListsService:

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

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

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

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

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

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

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

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

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

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

 <bindings configSource="Bindings.config" />

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

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

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

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

希望这能有所帮助。

< p >改变 从< / p >
<security mode="None">

<security mode="Transport">

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

如果你是通过编程而不是web。配置它:

new WebHttpBinding(WebHttpSecurityMode.Transport)

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

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

我添加了一个“互联服务”;我们的项目通过Visual Studio生成一个默认方法来创建客户端。

var client = new MyWebService.Client(MyWebService.Client.EndpointConfiguration.MyPort, _endpointUrl);

这个构造函数继承了ClientBase,并且在幕后使用它自己的方法Client.GetBindingForEndpoint(endpointConfiguration)来创建Binding:

public Client(EndpointConfiguration endpointConfiguration, string remoteAddress) :
base(Client.GetBindingForEndpoint(endpointConfiguration),
new System.ServiceModel.EndpointAddress(remoteAddress))

该方法对https服务和http服务有不同的设置。 当你想从http获取数据时,你应该使用TransportCredentialOnly:

System.ServiceModel.BasicHttpBinding result = new System.ServiceModel.BasicHttpBinding();
result.Security.Mode = System.ServiceModel.BasicHttpSecurityMode.TransportCredentialOnly;
 

对于https,你应该使用运输:

result.Security.Mode = System.ServiceModel.BasicHttpSecurityMode.Transport;
<!-- Binding settings for HTTPS endpoint -->
<binding name="yourServiceName">
<security mode="Transport">
<transport clientCredentialType="None" />
<!-- Don't use message -->
</security>
</binding>

我的解决方案,遇到了同样的错误消息,甚至比上面的更简单,我只是更新到basichttpbinding>

  <bindings>
<basicHttpsBinding>
<binding name="ShipServiceSoap" maxBufferPoolSize="512000" maxReceivedMessageSize="512000" />
</basicHttpsBinding>
</bindings>

下面的部分也一样:

  <client>
<endpoint address="https://s.asmx" binding="basicHttpsBinding" bindingConfiguration="ShipServiceSoap" contract="..ServiceSoap" name="ShipServiceSoap" />
</client>

如果您在将服务引用添加到调用https服务的应用程序时不小心,就会发生此错误

例如,如果你删除了以前的http://example.com/Service.svc服务引用,然后重新创建它,现在它是https://example.com/service.svc

如果不小心删除了旧客户端并在web中绑定。在重新创建服务引用之前,它将创建BasicHttpBinding_IService1而不是BasicHttpBinding_IService。然后,当你部署应用程序到实际的服务器,它会说'https是无效的期望http',因为它正在寻找BasicHttpBinding_IService1 &不再是BasicHttpBinding_IService。

与此同时,你尝试了以上所有的建议都没有结果。

我只是想把这个说出来。

在我的情况下,在web。配置我不得不改变binding=" basichttpbinding "绑定=“basicHttpBinding"在端点定义中复制相对bindingConfiguration到basicHttpBinding部分