【发布时间】:2015-04-24 08:58:02
【问题描述】:
我一直在努力通过 https 和 http 配置一个托管在 silverlight 4 应用程序中的 WCF 服务。到目前为止,我只设法让它通过 http 或 https 工作,但不能同时通过两者。我需要在两者上都调用它。
下面是我在 web.config 文件中的完整 system.serviceModel 部分。
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
<bindings>
<customBinding>
<binding name="TestApp.Data.customBinding0">
<binaryMessageEncoding/>
<httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"/>
</binding>
<binding name="TestApp.Data.customBinding0.https">
<binaryMessageEncoding/>
<httpsTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"/>
</binding>
</customBinding>
</bindings>
<services>
<service name="TestApp.Data" behaviorConfiguration="TestApp.Data">
<endpoint address="" binding="customBinding" bindingConfiguration="TestApp.Data.customBinding0" contract="TestApp.Data"/>
<endpoint address="mex" binding="mexHttpBinding" name="" contract="IMetadataExchange"/>
<endpoint address="" binding="customBinding" bindingConfiguration="TestApp.Data.customBinding0.https" contract="TestApp.Data"/>
<endpoint address="mexhttp" binding="mexHttpsBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="TestApp.Data" >
<serviceMetadata httpsGetEnabled="true" httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<dataContractSerializer maxItemsInObjectGraph="2147483646"/>
</behavior>
<behavior name="">
<serviceMetadata httpsGetEnabled="true" httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
下面是我完整的 ServiceReferences.ClientConfig
<configuration>
<system.serviceModel>
<bindings>
<customBinding>
<!--http-->
<binding name="CustomBinding_Data_http">
<binaryMessageEncoding />
<httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
</binding>
<!--https-->
<binding name="CustomBinding_Data">
<binaryMessageEncoding />
<httpsTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="//localhost/TestApp/Webservice/Data.svc" binding="customBinding" bindingConfiguration="CustomBinding_Data_http" contract="GetData.Data" name="CustomBinding_Data_http" />
<endpoint address="//localhost/TestApp/Webservice/Data.svc" binding="customBinding" bindingConfiguration="CustomBinding_Data" contract="GetData.GetData" name="CustomBinding_Data" />
</client>
通过上述配置,我只能通过 https 调用它,但我还需要能够通过 http 调用它。
当我尝试通过 http 调用它时,我收到以下错误消息
提供的 URI 方案“http”无效;预期的“https”。 参数名称:via
我应该对这些配置进行哪些更改才能让这个 WCF 东西在 https 和 http 上工作。
【问题讨论】:
-
我认为在同一个端点上不可能同时拥有 http 和 https。
标签: .net wcf wcf-binding wcf-security service-reference