[英]IIS 7.0 Web Service - Works on HTTP (80), Fails with error 404 on HTTPS (443)
IIS 7.0 on Windows 2008 Windows 2008上的IIS 7.0
WCF Web Service, .NET 4 from VS 2010 WCF Web服务,VS 2010中的.NET 4
Web service is installed via publishing and I have full admin rights on the server. Web服务是通过发布安装的,我在服务器上拥有完整的管理员权限。 There are several complicated methods, but there is a simple one that returns the build version.
有几种复杂的方法,但是有一种简单的方法可以返回构建版本。 If we can get this one working, I can fix them all - here is my interface:
如果我们可以解决这个问题,则可以全部修复-这是我的界面:
namespace MyNameSpace
{
[ServiceContract]
public interface WebInterface
{
[OperationContract]
[WebGet]
string GetVersion();
Attempt to connect via HTTP:// and everything works fine! 尝试通过HTTP://连接,一切正常!
Attempt to conenct via HTTPS:// I get a 404 file not found. 尝试通过HTTPS://连接,但未找到404文件。
I can reach the generic "You have created a web service..." page, including full web service path and the C# generic sample code when browsing to the exact same URL's both on HTTP and HTTPS. 当浏览到HTTP和HTTPS上完全相同的URL时,我可以到达通用的“您已创建Web服务...”页面,包括完整的Web服务路径和C#通用示例代码。
In C#, I have read that the certificate can cause trouble, and I have already implemented the delegate overload to approve our server certificate. 在C#中,我读到证书可能会引起麻烦,并且我已经实现了委托重载来批准我们的服务器证书。
I suspect missing one or more entries in the Web.config file, but I don't have a clue where to start. 我怀疑Web.config文件中缺少一个或多个条目,但是我不知道从哪里开始。 I have tried Google searching and Stack Overflow searching, but I haven't found the correct combination of search terms to help with this particular issue.
我曾尝试过Google搜索和Stack Overflow搜索,但没有找到正确的搜索字词组合来解决此特定问题。
Web Config: 网络配置:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="HttpGetMetadata">
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="LinkService" behaviorConfiguration="HttpGetMetadata">
<endpoint address="" contract="WebInterface" binding="basicHttpBinding" />
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
Help Please. 请帮助。
You're using the defaults for basicHttpBinding
, and the default security mode for that binding is None. 您正在使用
basicHttpBinding
的默认值,并且该绑定的默认安全模式是None。 You need to define the binding and set the security mode to Transport
in your config. 您需要定义绑定,并在配置中将安全模式设置为“
Transport
。 Add a Bindings section to your ServiceModel section, like this: 将Bindings部分添加到ServiceModel部分,如下所示:
<serviceModel>
<Bindings>
<basicHttpBinding name="secureBinding">
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</basicHttpBinding>
</Bindings>
</serviceModel>
Then you need to assign this binding to your endpoint via the bindingConfiguration
attribute, like this: 然后,您需要通过
bindingConfiguration
属性将此绑定分配给端点,如下所示:
<endpoint address=""
binding="basicHttpBinding"
bindingConfiguration="secureBinding"
contract="WebInterface" />
You'll probably want to enable httpsGetEnabled
as well: 您可能还希望启用
httpsGetEnabled
:
<serviceMetadata httpGetEnabled="true"
httpsGetEnabled="true" />
See BasicBinding with Transport Security (which is what the sample code is based on). 请参阅带有传输安全性的BasicBinding (这是示例代码所基于的)。
You can also google with terms like "BasicHttpBinding WCF SSL" and stuff like that - lots of examples and information on the web, it's just a matter of using the right words :) 您也可以使用诸如“ BasicHttpBinding WCF SSL”之类的术语和类似的内容在Google上进行搜索-网络上有很多示例和信息,仅需使用正确的词即可:)
Also, I'm not 100% confident that the transportClientCredential setting is correct for your scenario (it might need to be Certificate
), but I've done very little with SSL for WCF. 另外,我不是100%确信transportClientCredential设置对您的情况是正确的(它可能需要是
Certificate
),但是对于WCF,我对SSL所做的工作很少。
There may be other issues as well (like how IIS is set up on your machine), but the above is what's needed for the config. 可能还有其他问题(例如,如何在计算机上设置IIS),但是以上是配置所需要的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.