WCF使用Https服务

本文关键字:服务 Https 使用 WCF | 更新日期: 2023-09-27 17:52:48

目前我在我的应用程序中使用第三方Web服务,Web服务是单向SSL,但在我在Visual Studio中使用服务之后。在网上。配置文件绑定服务变成没有SSL,它应该下载Https,但现在是Http。下面是我的Web服务。这里的人。请帮助。由于

http://ws2.oriongateway.com:22836/willani2/services/ogltngws (No way SSL)
https://ws2.oriongateway.com:22837/willani2/services/ogltngws (1 way SSL)
我app.Config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.diagnostics>
        <sources>
            <!-- This section defines the logging configuration for My.Application.Log -->
            <source name="DefaultSource" switchName="DefaultSwitch">
                <listeners>
                    <add name="FileLog"/>
                    <!-- Uncomment the below section to write to the Application Event Log -->
                    <!--<add name="EventLog"/>-->
                </listeners>
            </source>
        </sources>
        <switches>
            <add name="DefaultSwitch" value="Information" />
        </switches>
        <sharedListeners>
            <add name="FileLog"
                 type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
                 initializeData="FileLogWriter"/>
            <!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log -->
            <!--<add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="APPLICATION_NAME"/> -->
        </sharedListeners>
    </system.diagnostics>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="OglTngWsSoap11Binding1" />
            </basicHttpBinding>
            <customBinding>
                <binding name="OglTngWsSoap12Binding1">
                    <textMessageEncoding messageVersion="Soap12" />
                    <httpTransport />
                </binding>
            </customBinding>
        </bindings>
        <client>
            <endpoint address="http://ws2.oriongateway.com:22836/willani2/services/ogltngws.OglTngWsHttpSoap12Endpoint/"
                binding="customBinding" bindingConfiguration="OglTngWsSoap12Binding1"
                contract="aService.OglTngWsPortType" name="OglTngWsHttpSoap12Endpoint1" />
            <endpoint address="http://ws2.oriongateway.com:22836/willani2/services/ogltngws.OglTngWsHttpSoap11Endpoint/"
                binding="basicHttpBinding" bindingConfiguration="OglTngWsSoap11Binding1"
                contract="aService.OglTngWsPortType" name="OglTngWsHttpSoap11Endpoint1" />
        </client>
    </system.serviceModel>
</configuration>

WCF使用Https服务

尝试下一步更改:

        <basicHttpBinding>
            <binding name="OglTngWsSoap11Binding1" />
            <security mode="Transport"> // add security mode
        </basicHttpBinding>

将端点地址更改为https,同时不要忘记更改端口:

            <endpoint address="https://ws2.oriongateway.com:22837/willani2/services/ogltngws.OglTngWsHttpSoap11Endpoint/"
            binding="basicHttpBinding" bindingConfiguration="OglTngWsSoap11Binding1"
            contract="aService.OglTngWsPortType" name="OglTngWsHttpSoap11Endpoint1" />