我知道有很多关于此的帖子,并且我已经浏览了搜索中出现的所有帖子并实现了所提到的所有内容。我有一个 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 文档,致力于这个项目,并且对服务、端点和绑定有了很好的掌握——这足以让我感到沮丧,甚至比我一无所知还要沮丧。
更新:仍在研究这个问题,当我尝试输入墨西哥地址的完整 URL 时,遇到了一个奇怪的错误。我改成这样:
address="https://prcwebs.com/Services/WebPostService.svc/mex"
并得到错误:
此服务的安全设置需要 Windows 身份验证,但
托管此服务的 IIS 应用程序未启用它。
我没有尝试使用 Windows 身份验证,安全设置未更改,仍设置为
找不到与绑定 WebHttpBinding 的端点的方案 https 相匹配的基地址。注册的基地址方案是[http] https://stackoverflow.com/questions/9817718/could-not-find-a-base-address-that-matches-scheme-https-for-the-endpoint-with-bi- 没有帮助,没有提到任何有帮助的内容找不到与绑定 WSHttpBinding 的端点的方案 http 相匹配的基地址 https://stackoverflow.com/questions/6846038/could-not-find-a-base-address-that-matches-scheme-http-for-the-endpoint-with-bin- 我正在使用运输安全,这不适用。尝试更改为不同的安全模式,仍然无法使网站正常工作。
Add multipleSiteBindingsEnabled="true"
to the serviceHostingEnvironment
并更新安全性以禁用客户端凭据:
<security mode="Transport">
<transport clientCredentialType="None"></transport>
</security>
EDIT我在 Windows 2003 下的最终工作版本具有以下配置。
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false" />
<!-- 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">
<transport clientCredentialType="None"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="WebPostService.WebPostServiceBehavior"
name="WcfService2.Service1">
<host>
<baseAddresses>
<add baseAddress="https://localhost/Service/Service1.svc"/>
</baseAddresses>
</host>
<endpoint address=""
binding="wsHttpBinding"
bindingConfiguration="SOAPBinding"
contract="WcfService2.IService1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex"
binding="mexHttpsBinding"
contract="IMetadataExchange">
</endpoint>
</service>
</services>
</system.serviceModel>
您可以使用 https 访问该网站,所以我猜安装的证书部分是正确的。如果您有任何想要与我的设置进行比较的内容,请告诉我。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)