How to Configuring WCF services to work with both HTTP and HTTPS - multiple bindings not working

回眸只為那壹抹淺笑 提交于 2020-02-08 07:23:27

问题


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

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.

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

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>

And my complete ServiceReferences.ClientConfig file is below

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


回答1:


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>


来源:https://stackoverflow.com/questions/25163113/how-to-configuring-wcf-services-to-work-with-both-http-and-https-multiple-bind

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!