【问题标题】:WCF consume Https serviceWCF 消费 Https 服务
【发布时间】:2014-03-23 13:20:21
【问题描述】:

目前我在我的应用程序中使用第三方 Web 服务,Web 服务是 1 路 SSL,但在我使用 Visual Studio 中的服务之后。在 Web.Config 文件绑定服务变得没有 SSL 它应该下载 Https 但现在是 Http。下面是我的网络服务。这里的任何人。请帮忙。谢谢

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

我的应用程序配置

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

【问题讨论】:

  • 出现任何错误或异常?
  • 你能显示 Web.config 吗?
  • 没有错误只是自动将服务更改为Http但我想要的原始是Https。

标签: c# wcf ssl


【解决方案1】:

尝试下一个更改:

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

让我知道它是否有效。

【讨论】:

  • 我收到这个错误,basicHttpBinding 的子元素安全性无效
  • 改用 wshttpbinding
  • Wallstrider,谢谢 在我忽略证书错误处理程序后,它就像魅力一样工作。非常感谢。 :)
猜你喜欢
  • 1970-01-01
  • 2014-12-02
  • 2014-05-30
  • 1970-01-01
  • 2015-02-06
  • 1970-01-01
  • 1970-01-01
  • 2012-10-15
  • 2012-02-25
相关资源
最近更新 更多