我访问 https://mywebsite/MyApp/Myservice.svc,得到以下错误信息:
(如果使用 http://,链接可以正常工作 )
"The service '/MyApp/MyService.svc'cannot be activated due to an exception during compile. 异常信息是无法为具有绑定 BasicHttpBinding 的端点找到与 https 方案匹配的基址。已注册的基址方案为 [http].";
编辑: 因此,如果我将 address=""
改为 address="https:// ..."
,就会出现这个错误:
"错误:不支持协议 'https'.....位于'https://.../Annotation.svc'的带有'"Annotation"'合约的 ChannelDispatcher 无法打开其 IChannelListener.";
我的 Web.Config
看起来是这样的:
<services>
<service behaviorConfiguration="AnnotationWCF.AnnotationBehavior"
name="AnnotationWCF.Annotation">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_Annotation"
contract="AnnotationWCF.Annotation" />
<endpoint address=""
binding="basicHttpBinding" bindingConfiguration="SecureTransport"
contract="AnnotationWCF.Annotation" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>;
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_Annotation" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</binding>
<binding name="SecureTransport" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
原来,我的问题出在使用负载平衡器处理 SSL,然后通过 http 发送到实际服务器,而实际服务器又发出了抱怨。
编辑:在与微软支持人员沟通后,我解决了自己的问题,但问题略有不同。
我的 silverlight 应用程序代码中的端点地址是通过 https 发送给负载平衡器的。 然后,负载平衡器将端点地址更改为 http,并指向实际的服务器。因此,在每台服务器的 Web 配置中,我为端点添加了一个 listenUri,即 http 而不是 https。
<endpoint address="" listenUri="http://[LOAD_BALANCER_ADDRESS]" ... />
我认为您试图以类似于以下配置的方式配置您的服务。这里有更多信息:[使用不同绑定值指定具有两个端点的服务][1]。此外,除了用于开发外,将 HTTP & HTTPS 端点设置为同一服务可能不是一个好主意。这有点违背 HTTPS 的初衷。希望对你有所帮助!
<service type="HelloWorld, IndigoConfig, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null">
<endpoint
address="http://computer:8080/Hello"
contract="HelloWorld, IndigoConfig, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"
binding="basicHttpBinding"
bindingConfiguration="shortTimeout"
</endpoint>
<endpoint
address="http://computer:8080/Hello"
contract="HelloWorld, IndigoConfig, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"
binding="basicHttpBinding"
bindingConfiguration="Secure"
</endpoint>
</service>
<bindings>
<basicHttpBinding
name="shortTimeout"
timeout="00:00:00:01"
/>
<basicHttpBinding
name="Secure">
<Security mode="Transport" />
</basicHttpBinding>
</bindings>
[1]: http://msdn.microsoft.com/en-us/library/ms733099.aspx "向下滚动以指定具有两个端点的服务...";