我的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>
也许我最好在代码中手动消费服务?