如何通过https使用Web服务

时间:2010-05-30 18:40:10

标签: c# asp.net web-services

我正在尝试使用位于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'。 参数名称:via

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

1 个答案:

答案 0 :(得分:1)

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

相关问题