如何配置WCF服务以同时使用HTTP和HTTPS-多个绑定不起作用 [英] How to Configuring WCF services to work with both HTTP and HTTPS - multiple bindings not working

查看:166
本文介绍了如何配置WCF服务以同时使用HTTP和HTTPS-多个绑定不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Iam fairly new to Silver-light and WCF, so please bear with me.

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

I have silver-light application that calls .svc service. The service is being called successfully over https but i would also like to make it work with calls over plain http.

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

What modifications do i need to make to my web.config and ServiceReferences.ClientConfig files below.

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

My complete system.serviceModel section in my Web.config file is this.

 <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>

推荐答案

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

Try to add another endpoint and another binding with no 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>

这篇关于如何配置WCF服务以同时使用HTTP和HTTPS-多个绑定不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆