我试图通过basicHttpBinding创建一个WCF服务,以便在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>
...
Run Code Online (Sandbox Code Playgroud)
<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>
Run Code Online (Sandbox Code Playgroud)
我正在使用能够正确检索所有元数据的WCFStorm进行连接,但是当我调用实际方法时,我得到:
提供的URI方案"https"无效; 预计'http'.参数名称:via
Joj*_*dez 231
尝试在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>
Run Code Online (Sandbox Code Playgroud)
eid*_*lon 54
添加这个作为答案,因为你不能在评论中做很多花哨的格式化.
我有同样的问题,除了我完全用代码创建和绑定我的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
Run Code Online (Sandbox Code Playgroud)
Ami*_*man 32
改变
<security mode="None">
Run Code Online (Sandbox Code Playgroud)
至
<security mode="Transport">
Run Code Online (Sandbox Code Playgroud)
在您的web.config文件中.此更改将允许您使用https而不是http
pat*_*onc 30
您是在Cassini(vs dev服务器)上运行此程序还是在安装了证书的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>
Run Code Online (Sandbox Code Playgroud)
和端点
<endpoint address="..." binding="wsHttpBinding"
bindingConfiguration="WsSecured" contract="IYourContract" />
Run Code Online (Sandbox Code Playgroud)
此外,请确保更改客户端配置以启用传输安全性.
小智 20
我有与OP相同的问题.我的配置和情况完全相同.在Visual Studio中的测试项目中创建服务引用并确认该服务正在运行后,我最终将其缩小为WCFStorm中的问题.在Storm中,您需要单击"配置"设置选项(而不是"客户端配置").单击后,单击弹出对话框中的"安全"选项卡.确保"身份验证类型"设置为"无"(默认为"Windows身份验证").Presto,它的作品!我总是在WCFStorm中测试我的方法,因为我正在构建它们,但从未尝试使用它来连接已经在SSL上设置的方法.希望这有助于某人!
LCJ*_*LCJ 18
我在custom binding
场景中遇到了同样的异常.使用这种方法的任何人都可以检查这一点.
我实际上是从local WSDL
文件中添加服务引用.它已成功添加,并且需要将自定义绑定添加到配置文件中.但是,实际的服务是https; 不是http.所以我将httpTransport elemet更改为 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>
Run Code Online (Sandbox Code Playgroud)
参考
Fat*_*gun 12
遇到同样的问题,这就是我的解决方案最终结果:
<basicHttpsBinding>
<binding name="VerificationServicesPasswordBinding">
<security mode="Transport">
</security>
</binding>
<binding name="VerificationServicesPasswordBinding1" />
</basicHttpsBinding>
Run Code Online (Sandbox Code Playgroud)
我基本上用Https替换了每次出现的Http.如果您愿意,可以尝试添加它们.
如果您以编程方式而不是在web.config中执行此操作,则其:
new WebHttpBinding(WebHttpSecurityMode.Transport)
Run Code Online (Sandbox Code Playgroud)