我知道有很多关于这方面的帖子,我已经浏览过所有这些文章,这些文章都是我搜索到的,并且实现了所有提到的内容。我有一个WCF web服务,它可以在我的本地系统上使用HTTP,它可以在HTTP上的服务器上工作。但是客户端需要通过HTTPS来实现这一点。在这个网站和其他网站上发布的文章告诉我,这并不像它应该的那样直接,因为在此之前,ASMX web服务“刚刚工作”,不需要复杂的配置。
我的当前配置出现了以下错误:
找不到与绑定WSHttpBinding的端点的方案https匹配的基址。注册的基本地址计划是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 -我使用传输安全,这不适用。尝试换到不同的安全模式,仍然无法使站点工作。
发布于 2013-01-30 12:32:06
将multipleSiteBindingsEnabled="true"
添加到serviceHostingEnvironment
并更新安全性以禁用客户端凭据:
<security mode="Transport">
<transport clientCredentialType="None"></transport>
</security>
编辑我在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访问网站,所以我想安装的证书部分是正确的。如果你有什么想和我比较的话,告诉我。
发布于 2013-02-01 08:48:02
您对HTTPS使用了错误的绑定。
有两个独立的绑定类。wsHttpBinding和wsHttpsBinding注意到了s,您需要在绑定下为HTTPS添加一个wsHttpsBinding,并且需要一个新的端点来进行绑定。
另外,您所看到的特殊错误--通常情况下,我将查看IIS是否从该位置为https设置过。
发布于 2013-02-08 01:19:36
我用了这个,它对我有用,也许它能帮到你
为了在WCF WsHttp绑定上启用Https,应该在web.config文件中更改一些简单的步骤。
这些步骤是:
在服务的web.config文件中启用传输级安全性:
在此步骤中,需要将安全模式从“无”更改为“传输”。下面的代码显示了如何做到这一点:
<bindings>
<wsHttpBinding>
<binding name="TransportSecurity">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
绑定并指定HTTPS配置
现在,您需要将绑定、预览步骤与终结点关联起来。使用bindingConfiguration标记指定绑定名称。您还需要指定承载服务的地址。下面的代码显示了如何做到这一点。
<service name="WCFWSHttps.Service1" behaviorConfiguration="WCFWSHttps.Service1Behavior">
<!-- Service Endpoints -->
<endpoint address=https://localhost/WCFWSHttps/Service1.svc binding="wsHttpBinding" bindingConfiguration="TransportSecurity" contract="WCFWSHttps.IService1"/>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
</service>
。您还需要将httpGetEnabled更改为serviceMetaData中的httpsGetEnabled。下面的代码显示了如何做到这一点:
<serviceMetadata httpsGetEnabled="true"/>
希望它能帮上忙
https://stackoverflow.com/questions/14611514
复制