【问题标题】:How to Configuring WCF services to work with both HTTP and HTTPS - multiple bindings not working如何配置 WCF 服务以同时使用 HTTP 和 HTTPS - 多个绑定不起作用
【发布时间】:2014-09-29 13:11:24
【问题描述】:

我对 Silver-light 和 WCF 还很陌生,所以请多多包涵。

我有调用 .svc 服务的 Silver-light 应用程序。该服务已通过 https 成功调用,但我也想让它与普通 http 的调用一起使用。

我需要对下面的 web.config 和 ServiceReferences.ClientConfig 文件进行哪些修改。

我的 Web.config 文件中完整的 system.serviceModel 部分是这样的。

 <system.serviceModel>     
    <bindings>
        <customBinding>
            <binding name="MyApp.Web.GetData.customBinding" receiveTimeout="00:30:00" sendTimeout="00:30:00" >
                <binaryMessageEncoding/>
                <httpsTransport/>
            </binding>
        </customBinding>
    </bindings>
    <services>
        <service name="MyApp.Web.GetData">
            <endpoint address="" binding="customBinding" bindingConfiguration="MyApp.Web.GetData.customBinding" contract="MyApp.Web.GetData" />
            <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
        </service>
    </services>      
    <behaviors>
        <serviceBehaviors>
            <behavior name="MyApp.Web.GetData">
                <serviceMetadata httpsGetEnabled="true" httpGetEnabled="true"/>
                <serviceDebug includeExceptionDetailInFaults="true"/>
                <dataContractSerializer maxItemsInObjectGraph="2147483646"/>
            </behavior>
            <behavior name="">
                <serviceMetadata httpsGetEnabled="true" httpGetEnabled="true" />
                <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
        </serviceBehaviors>
    </behaviors>       
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>

下面是我完整的 ServiceReferences.ClientConfig 文件

<configuration>
<system.serviceModel>
    <bindings>
        <customBinding>
            <binding name="CustomBinding_GetData">
                <binaryMessageEncoding />
                <httpsTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
           </binding>
        </customBinding>
    </bindings>
    <client>
        <endpoint address="//localhost/MyApp.Web/Webservice/GetData.svc"
            binding="customBinding" bindingConfiguration="CustomBinding_GetData"
            contract="GetData.GetData" name="CustomBinding_GetData" />
    </client>
</system.serviceModel>

【问题讨论】:

    标签: web-services wcf silverlight-4.0 svc service-model


    【解决方案1】:

    尝试添加另一个端点和另一个没有 ssl 的绑定:

            </customBinding>
        </bindings>
        <client>
            <endpoint address="//localhost/MyApp.Web/Webservice/GetData.svc"
                binding="customBinding" bindingConfiguration="CustomBinding_GetData-ssl"
                contract="GetData.GetData" name="CustomBinding_GetData-ssl" />
            <endpoint address="//localhost/MyApp.Web/Webservice/GetData.svc"
                binding="customBinding" bindingConfiguration="CustomBinding_GetData"
                contract="GetData.GetData" name="CustomBinding_GetData" />
        </client>
    </system.serviceModel>
    

    【讨论】:

      猜你喜欢
      • 2014-09-23
      • 2012-06-19
      • 1970-01-01
      • 2011-06-15
      • 2011-02-08
      • 1970-01-01
      • 2023-03-25
      • 1970-01-01
      • 2011-04-18
      相关资源
      最近更新 更多