【发布时间】:2011-12-23 17:36:33
【问题描述】:
我的 WCF 服务应用程序通过 http 和 https 工作,但是,当我在客户端中向它添加服务引用(使用 https url)时,Visual Studio 2010 将配置文件中的端点设置为 http。它似乎不像将配置端点更改为 https 那样简单,因为幕后有多个文件在使用 xsd 并引用 http 端点。如何设置我的服务/客户端以强制使用 https 以便正确设置端点?
当我尝试手动更改配置文件中的端点并将安全模式设置为“传输”时,我收到此错误:
异常消息:没有端点监听 https://myservice/AvailabilityService.svc 可以接受 信息。这通常是由不正确的地址或 SOAP 操作引起的。 有关详细信息,请参阅 InnerException(如果存在)。
但是,我可以在 IE 中看到该端点,并且正在本地调试。在我使用 https 添加我的服务引用并搜索其 http 等效项的解决方案后,它会找到一个引用 http 的 wsdl 文件、一个 configuration.svcinfo 和一个使用 http url 而不是 https 的 configuration91.svcinfo
这是我的服务器端配置:
<?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>
也许我最好手动使用代码中的服务?
【问题讨论】:
标签: .net wcf ssl https endpoint