.net 使用https端点添加WCF服务引用
我的WCF服务应用程序通过http和https工作,但是,当我在客户端中向其添加服务引用(带有https url)时,Visual Studio 2010会将配置文件中的端点设置为http。它看起来不像将配置端点更改为https那么简单,因为有多个文件在幕后使用xsd进行操作并引用http端点。我如何设置我的服务/客户端以强制https,以便它正确设置端点 当我尝试手动更改配置文件中的端点并将安全模式设置为“Transport”时,会出现以下错误: 异常消息:没有端点正在侦听 那可以接受 消息这通常是由不正确的地址或SOAP操作引起的。 有关更多详细信息,请参阅InnerException(如果存在) 然而,我可以在IE中看到该端点,并且正在本地调试。在我使用https添加服务引用并搜索解决方案的http等价物后,它会找到一个引用http的wsdl文件、一个configuration.svcinfo和一个利用http url而不是https的configuration91.svcinfo 这是我的服务器端配置:.net 使用https端点添加WCF服务引用,.net,wcf,ssl,https,endpoint,.net,Wcf,Ssl,Https,Endpoint,我的WCF服务应用程序通过http和https工作,但是,当我在客户端中向其添加服务引用(带有https url)时,Visual Studio 2010会将配置文件中的端点设置为http。它看起来不像将配置端点更改为https那么简单,因为有多个文件在幕后使用xsd进行操作并引用http端点。我如何设置我的服务/客户端以强制https,以便它正确设置端点 当我尝试手动更改配置文件中的端点并将安全模式设置为“Transport”时,会出现以下错误: 异常消息:没有端点正在侦听 那可以接受 消息这
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IAvailabilityService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://myservice/AvailabilityService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IAvailabilityService"
contract="PaymentAvailabilityService.IAvailabilityService"
name="BasicHttpBinding_IAvailabilityService" />
</client>
</system.serviceModel>
。。和客户端配置:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IAvailabilityService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://myservice/AvailabilityService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IAvailabilityService"
contract="PaymentAvailabilityService.IAvailabilityService"
name="BasicHttpBinding_IAvailabilityService" />
</client>
</system.serviceModel>
也许我最好手动使用代码中的服务?您需要将绑定更改为使用传输安全性来使用HTTPS 应为https和客户端配置服务器端绑定:
<bindings>
<basicHttpBinding>
<binding name="httpsBinding" allowCookies="true" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="yourNamespace.YourService" behaviorConfiguration="yourBehaviors">
<endpoint contract="yourNamespace.YourService" binding="basicHttpBinding" bindingConfiguration="httpsBinding" />
</service>
</services>
谢谢你,看来你成功了。我想我的假设是不正确的,WCF服务应用程序在引擎盖下做了一些这样的事情,而它在WCF服务库中更为明确。@ChrisKlepeis-很高兴为您提供帮助!我认为在您的场景中,它是在幕后做最基本的事情,即使用std开箱即用设置打开basichttpbinding。您可以通过https访问MEX enpoint,因为您在元数据行为中启用了它。