WCF使用Https服务

时间:2014-03-23 13:20:22

标签: c# wcf ssl

目前我在我的应用程序中使用第三方Web服务,Web服务是单向SSL,但在我使用Visual Studio中的服务之后。在Web.Config文件绑定服务变成没有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>

1 个答案:

答案 0 :(得分:0)

尝试下一步更改:

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

让我知道它是否有效。