且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

调用使用WCF通过HTTP和HTTPS Web服务

更新时间:2022-11-03 16:19:02

我找到了答案周围挖MSDN

I found an answer digging around MSDN.

在我的情况下,我使用的是自定义绑定:

In my case, I was using a custom binding:

<customBinding>
    <binding name="jsonpBinding">
        <jsonpMessageEncoding/>
        <httpTransport manualAddressing="true"/>
    </binding>
</customBinding>

这是在服务中引用

<services>
    <service name="{YourInfoHere}">
        <endpoint address="" binding="customBinding" bindingConfiguration="jsonpBinding" behaviorConfiguration="{YourInfoHere}" contract="{YourInfoHere}"/>
    </service>
</services>

添加了用于httpsTransport第二个结合,然后是使用的绑定奏效了第二个服务。最终输出:

Adding a second binding that used httpsTransport and then a second service that used that binding did the trick. Final output:

    <services>
        <service name="{YourInfoHere}">
            <endpoint address="" binding="customBinding" bindingConfiguration="jsonpBinding" behaviorConfiguration="{YourInfoHere}" contract="{YourInfoHere}"/>
            <endpoint address="" binding="customBinding" bindingConfiguration="jsonpBindingHttps" behaviorConfiguration="{YourInfoHere}" contract="{YourInfoHere}"/>
        </service>
    </services>
    <bindings>
        <customBinding>
            <binding name="jsonpBinding">
                <jsonpMessageEncoding/>
                <httpTransport manualAddressing="true"/>
            </binding>
            <binding name="jsonpBindingHttps">
                <jsonpMessageEncoding/>
                <httpsTransport manualAddressing="true" />
            </binding>
        </customBinding>
    </bindings>

可能不是很理想,但它的作品。这些只是我取得了令SSL工作的变化。因为它是所有在绑定和放大器;交通方面,code保持不变。

May not be ideal, but it works. These were the only changes I made to make SSL work. Since it is all in the binding & transport, the code remains the same.

相关链接MSDN:


  1. 自定义绑定:http://msdn.microsoft.com/en-us/library/ms731377.aspx

  2. HttpTransport:http://msdn.microsoft.com/en-us/library/system.servicemodel.channels.httptransportbindingelement.aspx

  3. HttpsTransport:http://msdn.microsoft.com/en-us/library/system.servicemodel.channels.httpstransportbindingelement.aspx