wcf - 不支持“https”协议
问题描述
我正在使用托管在 IIS 中的 WCF 服务,但是当我尝试导航到端点时,我收到错误“不支持协议'https'”。它托管在本地运行 Windows 10 的 IIS 10 中。
该服务正在使用带有 TransportWithMessageCredential 的 wsHttpBinding。
此错误与 SSL 证书或 IIS 有关吗?
我的本地计算机 > 个人证书存储中已经有一个有效的本地主机证书。
到目前为止我尝试过的
- 将 httpsGetUrl 属性设置为 .svc 端点。
- 选中的 IIS 设置和默认协议设置为“http”,这意味着启用了 http 和 https 协议。
- 检查应用程序池是否使用 .NET Framework 4.0
- 重新启动应用程序池
如果有人可以帮助我,我将不胜感激。
这是当前的配置:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="XXX.Zoo.WebServices.ZooServices_3_0"
behaviorConfiguration="ZooServices_3_0_Behavior">
<endpoint
address="https://localhost/Zootest_3_0/ZooServices_3_0.svc"
binding="wsHttpBinding"
bindingConfiguration="ZooServices_3_0_Binding"
contract="XXX.Zoo.WebServices.IZooServices_3_0" />
<endpoint
address="https://localhost/Zootest_3_0/ZooServices_3_0.svc/mex"
binding="mexHttpsBinding"
contract="IMetadataExchange" />
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="ZooServices_3_0_Binding"
maxReceivedMessageSize="2147483647"
maxBufferPoolSize="2147483647" >
<readerQuotas
maxDepth="2147483647"
maxStringContentLength="2147483646"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647"/>
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="None"
proxyCredentialType="None" realm="" />
<message clientCredentialType="Certificate"
negotiateServiceCredential="true" algorithmSuite="Default"
establishSecurityContext="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="ZooServices_3_0_Behavior">
<serviceMetadata httpsGetEnabled="true"
httpsGetUrl="https://localhost/Zootest_3_0/ZooServices_3_0.svc" />
<serviceDebug includeExceptionDetailInFaults="False" />
<!--The serviceCredentials behavior defines a service
certificate which is used by the service to authenticate
itself to its clients and to provide message protection. -->
<serviceCredentials>
<serviceCertificate
findValue="localhost"
storeLocation="LocalMachine"
storeName="My"
x509FindType="FindBySubjectName" />
<clientCertificate>
<authentication
certificateValidationMode="ChainTrust"/>
</clientCertificate>
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
解决方案
如果要启用 https 协议支持,则应将使用传输传输模式的 https 端点添加到服务中。然后我们应该在 IIS 站点绑定模块中设置 https 协议站点绑定。
我做了一个demo,希望对你有用。服务器端。
[ServiceContract]
public interface IService1
{
[OperationContract]
string GetData(int value);
}
public class Service1 : IService1
{
public string GetData(int value)
{
return string.Format("You entered: {0}", value);
}
}
网页配置
<system.serviceModel>
<services>
<service name="WcfService1.Service1" behaviorConfiguration="mybehavior">
<endpoint address="" binding="basicHttpBinding" contract="WcfService1.IService1" bindingConfiguration="https"></endpoint>
<endpoint address="" binding="basicHttpBinding" contract="WcfService1.IService1" bindingConfiguration="http"></endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"></endpoint>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="https">
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="None"></transport>
</security>
</binding>
<binding name="http">
<security mode="None">
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="mybehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
IIS。
这里有一些链接,希望对你有用。WCF 服务未通过https://social.msdn.microsoft.com/Forums/vstudio/en-US/d42fc165-052d-476a-9580-1240b3d0293d/specify-endpoint-in-wcf-webconfig?forum=从邮递员处获得wcf
如果有什么我可以帮忙的,请随时告诉我。
推荐阅读
- ios - 在 ScrollView 中设置 ContentView 高度以动态更改
- regex - 正则表达式捕获日期,然后是文本
- kiwi-tcms - 升级到 Kiwi 5.3.1 后无法通过 Kiwi TCMS Python API 创建测试运行
- xslt - 开始运行撒克逊
- r - 编写函数以将行添加到数据框中
- vba - 如果 IsNumeric(num) And Len(num) > 1 计算一个数字的 false ?
- python - Pandas,将元组列表转换为 DataFrame 尴尬的列标题。
- smalltalk - Smalltalk 的 message to:do: 是如何在幕后实现的?
- data-structures - 用于树的孩子的适当数据结构
- arrays - VBA循环将行添加到被错误覆盖的数组?