我正在尝试创建一个可以接受http和https流量的休息服务。这样做的原因是我的公司为我们的客户提供托管和非托管解决方案。在托管解决方案中,所有流量都通过F5,它会剥离SSL并以常规http方式将其转发到我们的服务器。
非托管解决方案的Web服务器处理SSL(因此,服务器期望https安全性)。
绑定最初定义如下:
<webHttpBinding>
<binding closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="64" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
</security>
</binding>
</webHttpBinding>
但是,这对我们的非托管客户不起作用。然后我把它改成了这个
<webHttpBinding>
<binding closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="64" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
</security>
</binding>
</webHttpBinding>
但是,正如您所猜测,这对我们的托管客户不起作用。
是否可以使用.NET 4.0框架的WCF休息服务同时接受http和https流量?
我试过这个:
<webHttpBinding>
<binding name="normalRestBinding" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="64" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
</security>
</binding>
<binding name="secureRestBinding" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="64" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
</security>
</binding>
</webHttpBinding>
使用此服务定义:
<service name="theService" behaviorConfiguration="RestServiceBehavior">
<endpoint name="normalRestEndpoint" address="" behaviorConfiguration="RestEndpoint" binding="webHttpBinding" bindingConfiguration="normalRestBinding" contract="theContract">
<identity>
<dns />
</identity>
</endpoint>
<endpoint name="secureRestEndpoint" address="" behaviorConfiguration="RestEndpoint" binding="webHttpBinding" bindingConfiguration="secureRestBinding" contract="theContract">
<identity>
<dns />
</identity>
</endpoint>
</service>
使用这些,我现在在尝试通过常规http:
访问端点时收到此错误无法找到与绑定WebHttpBinding的端点的方案https匹配的基址。注册的基地址方案是[http]。
非常感谢任何帮助。
谢谢!
答案 0 :(得分:0)
能够弄清楚这一点。
我在问题的底部提出的代码很好。
要解决该错误消息,我必须确保在我尝试使用此Web配置的服务器上的IIS中存在https绑定。
很抱歉自我回答,但我不想让这个开放,有人浪费时间试图为我回答!
谢谢!