WCF 调用收到“访问被拒绝”通过 .NET 4 上的 HTTPS
以前从未遇到过问题,但升级到 .NET 4 后,我在尝试通过 HTTPS 调用 WCF 方法时收到“访问被拒绝”的消息。如果我使用 HTTP 而不是 HTTPS,一切正常。有什么可能的解决方案吗?如果需要,我可以提供更具体的信息。
web.config
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="some_product.SomeServiceAspNetAjaxBehavior">
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="some_product.SomeServiceAspNetAjaxBehavior">
<enableWebScript />
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<services>
<service name="some_product.SomeService">
<endpoint address="" behaviorConfiguration="some_product.SomeServiceAspNetAjaxBehavior" bindingConfiguration="BasicHttpBinding_SomeService" binding="webHttpBinding" contract="some_product.SomeService"/>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpsBinding_SomeService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="true" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192"
maxArrayLength="16384" maxBytesPerRead="4096"
maxNameTableCharCount="16384"/>
<security mode="Transport">
<transport clientCredentialType="Windows"
proxyCredentialType="None" realm=""/>
</security>
</binding>
<binding name="BasicHttpBinding_SomeService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="true" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
<message clientCredentialType="UserName" algorithmSuite="Default"/>
</security>
</binding>
</basicHttpBinding>
<webHttpBinding>
<binding name="BasicHttpBinding_SomeService" maxReceivedMessageSize="300000" allowCookies="true" >
<readerQuotas maxStringContentLength="300000" />
</binding>
</webHttpBinding>
</bindings>
<client>
<endpoint address="/someurl/SomeService.svc" binding="webHttpBinding" bindingConfiguration="BasicHttpBinding_SomeService" contract="some_product.SomeService" name="BasicHttpBinding_SomeService"/>
<endpoint address="/someurl/SomeService.svc" binding="webHttpBinding" bindingConfiguration="BasicHttpsBinding_SomeService" contract="some_product.SomeService" name="BasicHttpsBinding_SomeService"/>
</client>
</system.serviceModel>
注意:通过 HTTP 工作得非常好。问题仅存在于 HTTPS 下。
Never had problems before but after upgrading to .NET 4, I am getting "Access is Denied" when trying to invoke a WCF method over HTTPS. If I use HTTP instead of HTTPS, everything works fine. Any possible solutions for this? I can provide more specific information if requested.
web.config
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="some_product.SomeServiceAspNetAjaxBehavior">
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="some_product.SomeServiceAspNetAjaxBehavior">
<enableWebScript />
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<services>
<service name="some_product.SomeService">
<endpoint address="" behaviorConfiguration="some_product.SomeServiceAspNetAjaxBehavior" bindingConfiguration="BasicHttpBinding_SomeService" binding="webHttpBinding" contract="some_product.SomeService"/>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpsBinding_SomeService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="true" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192"
maxArrayLength="16384" maxBytesPerRead="4096"
maxNameTableCharCount="16384"/>
<security mode="Transport">
<transport clientCredentialType="Windows"
proxyCredentialType="None" realm=""/>
</security>
</binding>
<binding name="BasicHttpBinding_SomeService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="true" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
<message clientCredentialType="UserName" algorithmSuite="Default"/>
</security>
</binding>
</basicHttpBinding>
<webHttpBinding>
<binding name="BasicHttpBinding_SomeService" maxReceivedMessageSize="300000" allowCookies="true" >
<readerQuotas maxStringContentLength="300000" />
</binding>
</webHttpBinding>
</bindings>
<client>
<endpoint address="/someurl/SomeService.svc" binding="webHttpBinding" bindingConfiguration="BasicHttpBinding_SomeService" contract="some_product.SomeService" name="BasicHttpBinding_SomeService"/>
<endpoint address="/someurl/SomeService.svc" binding="webHttpBinding" bindingConfiguration="BasicHttpsBinding_SomeService" contract="some_product.SomeService" name="BasicHttpsBinding_SomeService"/>
</client>
</system.serviceModel>
Note: Works PERFECTLY fine over HTTP. Problem ONLY exists under HTTPS.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在您的设置中,您没有定义安全性 - 因此您只能使用 http 连接:
如果您想使用 https,则需要启用传输安全性:
更新:现在您已经定义了您的安全 HTTPS 绑定配置:
当然,您还需要配置端点来使用该绑定配置!
仅定义绑定配置而不具有实际引用它的端点并没有真正的帮助......
With your setup, you have no security defined -- thus you can only connect using http:
If you want to use https, you need to enable transport security:
Update: Now that you have defined your secure HTTPS binding configuration:
you also need to configure an endpoint to use that binding configuration, of course!
Just defining the binding configuration without having an endpoint that actually refers to it doesn't really help......