我有一个 WCF 服务,由于这个错误,我已经将其归结为几乎没有。它把我逼上了墙。这就是我现在所拥有的。
一个非常简单的 WCF 服务,具有一个返回值为“test”的字符串的方法。
一个非常简单的 Web 应用程序,它使用该服务并将字符串的值放入标签中。
在 Win 2003 上使用 SSL 证书运行 IIS 6 的 Web 服务器。
同一服务器上其他可用的 WCF 服务。
我将 WCF 服务发布到它的 https 位置
我在 VS 中以 Debug模式运行 Web 应用程序,它运行良好。
我将 Web 应用程序发布到 WCF 服务所在的同一台服务器上的 https 位置,该服务器位于同一台 SSL 证书下
我得到,“远程服务器返回错误:(403) 禁止访问”
我几乎更改了 IIS 以及 WCF 和 Web 应用程序中的所有设置,但都无济于事。我比较了有效的 WCF 服务中的设置,一切都是一样的。
以下是 WCF 服务和 WEB 应用程序的 web.config 中的设置:
问题似乎与 Web 应用程序有关,但我没有想法。任何想法:
WCF 服务:
<system.serviceModel>
<bindings>
<client />
<services>
<service behaviorConfiguration="Ucf.Smtp.Wcf.SmtpServiceBehavior" name="Ucf.Smtp.Wcf.SmtpService">
<host>
<baseAddresses>
<add baseAddress="https://test.net.ucf.edu/webservices/Smtp/" />
</baseAddresses>
</host>
<endpoint address="" binding="wsHttpBinding" contract="Ucf.Smtp.Wcf.ISmtpService" bindingConfiguration="SSLBinding">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="Ucf.Smtp.Wcf.SmtpServiceBehavior">
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" httpsHelpPageEnabled="True"/>
</behavior>
</serviceBehaviors>
</behaviors>
网络应用:
<system.serviceModel>
<bindings><wsHttpBinding>
<binding name="WSHttpBinding_ISmtpService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
establishSecurityContext="true" />
</security>
</binding>
<client>
<endpoint address="https://net228.net.ucf.edu/webservices/smtp/SmtpService.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ISmtpService"
contract="SmtpService.ISmtpService" name="WSHttpBinding_ISmtpService">
<identity>
<dns value="localhost" />
</identity>
</client>
</system.serviceModel>
最佳答案
在这个问题上花费了数小时之后,我将回答我自己的问题。我希望这可以帮助所有其他试图解决这个问题的人。我们终于让网络管理员参与并解决了这个问题。
这是场景和解决方案:
我们有一个生产服务器 - 一切正常。 我们有一个测试服务器 - 我们收到 403 forbidden 错误。 本地调试工作正常。
所有设置都是相同的,或者我们认为是这样。
有一个设置是错误的。在 IIS 的目录安全选项卡下的 Web 服务的虚拟目录的属性中,第二个编辑按钮用于 IP 限制。我们被设置为拒绝访问除应该包含测试服务器 IP 的列表之外的所有 IP。测试网络服务器的 IP 未被授予权限。它没有权限的原因是它最近是从生产虚拟服务器克隆的,并且从未调整此设置以添加测试虚拟服务器。
关于c# - 被 "The remote server returned an error: (403) Forbidden"与 https 中的 WCF 服务难住了,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2961225/