【问题标题】:How to consume webservices over https如何通过 https 使用 web 服务
【发布时间】:2011-02-25 18:13:02
【问题描述】:

我正在尝试使用位于https://TestServices/ServiceList.asmx 的网络服务。当我尝试向我的 C# 库类项目添加服务引用时,我的 app.config 文件如下所示:

<system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="TestServicesSoap" closeTimeout="00:01:00" openTimeout="00:01:00"
                    receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
                    bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferSize="50000000" maxBufferPoolSize="524288" maxReceivedMessageSize="50000000"
                    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                    useDefaultWebProxy="true">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <security mode="None">
                        <transport clientCredentialType="None" proxyCredentialType="None"
                            realm="">
                        </transport>
                        <message clientCredentialType="UserName" algorithmSuite="Default" />
                    </security>
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://TestServices/ServiceList.asmx"
                binding="basicHttpBinding" bindingConfiguration="TestServicesSoap"
                contract="TestServices.TestServicesSoap" name="TestServicesSoap" />
        </client>
    </system.serviceModel>

即使我出于某种原因尝试添加对 https://TestServices/ServiceList.asmx 的服务引用,端点地址仍指向 http://TestServices/ServiceList.asmx。我尝试将 http 更改为 https,但出现以下错误:

提供的 URI 方案“https”无效;预期的“http”。 参数名称:通过

在 https 上使用 web 服务的正确方法是什么?

【问题讨论】:

标签: c# asp.net web-services


【解决方案1】:

在绑定中你有&lt;security mode="None"...,我相信如果你想使用https,你需要将它设置为&lt;security mode="Transport"...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-09
    • 2018-03-31
    • 2011-09-27
    • 2012-03-22
    • 1970-01-01
    • 2012-03-17
    相关资源
    最近更新 更多