【发布时间】:2013-01-14 17:05:29
【问题描述】:
我知道有很多关于此的帖子,并且我已经浏览了所有在我的搜索中出现的帖子并实施了提到的所有内容。我有一个 WCF Web 服务,可以在我的本地系统上运行 HTTP,它也可以在服务器上运行 HTTP。但是客户端要求它通过 HTTPS 工作。这个网站和其他网站上的大量帖子告诉我,这并不像应有的那么简单,因为在此之前,ASMX Web 服务“正常工作”并且不需要复杂的配置。
我的当前配置出现以下错误:
找不到与方案 https 匹配的基地址 具有绑定 WSHttpBinding 的端点。注册的基地址方案 是 [http]。
这是我目前的代码,经过几天的尝试配置它无济于事:
<system.serviceModel>
<!-- -->
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" >
<baseAddressPrefixFilters>
<add prefix="https://mysite.com"/>
<add prefix="http://mysite.com"/>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
<!-- Set up Custom Behaviors -->
<behaviors>
<endpointBehaviors>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="WebPostService.WebPostServiceBehavior">
<serviceMetadata httpsGetEnabled="true" httpsGetUrl="WebPostServices.svc/mex" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<!-- Set up the binding configuration -->
<bindings>
<wsHttpBinding>
<binding name="SOAPBinding"
>
<security mode="Transport">
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service
behaviorConfiguration="WebPostService.WebPostServiceBehavior"
name="WebPostService.WebPostService"
>
<host>
<baseAddresses>
<add baseAddress="https://mysite.com/Services/WebPostService.svc"/>
</baseAddresses>
</host>
<endpoint address=""
binding="wsHttpBinding"
bindingConfiguration="SOAPBinding"
contract="WebPostService.IWebPostService"
>
<identity>
<dns value="mysite.com" />
</identity>
</endpoint>
<endpoint
address="mex"
binding="mexHttpsBinding"
contract="IMetadataExchange"
>
</endpoint>
</service>
</services>
</system.serviceModel>
我做错了什么,我怎样才能让它通过 HTTPS 工作?我很沮丧,这并不像它应该的那么简单。在这个项目上工作的几个月里,我一直在 MSDN 的 WCF 文档中埋头苦干,并且对服务、端点和绑定有很好的掌握——这比我完全不了解更让我感到沮丧。
更新:仍在处理此问题,但在尝试为 mex 地址输入完整 URL 时遇到了一个奇怪的错误。我改成这样:
address="https://prcwebs.com/Services/WebPostService.svc/mex"
并得到错误:
此服务的安全设置需要 Windows 身份验证,但 托管此服务的 IIS 应用程序未启用它。
我没有尝试使用 Windows 身份验证,安全设置没有更改,仍然设置为
Could not find a base address that matches scheme https for the endpoint with binding WebHttpBinding. Registered base address schemes are [http] - 没有帮助,没有提到会有所帮助 Could not find a base address that matches scheme http for the endpoint with binding WSHttpBinding - 我正在使用运输安全,这不适用。尝试更改为不同的安全模式,仍然无法使网站正常工作。
【问题讨论】:
-
您是在本地运行服务并收到 HTTPS 错误,还是由 IIS 提供服务而您收到该错误?
-
它由 IIS 提供服务。在本地,我没有设置 HTTPS,只是创建了默认项目,一切正常。发布到 Web 服务器时,一切正常,直到我尝试使用 HTTPS 访问该站点,这让我经历了异常困难的迭代,以修复 web.config 以使用 HTTPS,这看起来很简单,但到目前为止没有任何效果。
-
如果托管在 IIS 中,则不需要任何基地址。
-
我认为基地址是必要的,因为有多个地址应用于此服务器。如果我删除它,它会给我错误“这个集合已经包含一个带有方案 http 的地址。这个集合中的每个方案最多可以有一个地址。参数名称:项目”
-
不应基于服务器,而应基于部署此服务的网站。