2

我已经查看了stackoverflow和互联网,仍然找不到解决方案我已经设置了一个带有“https”端点的自定义basichttpbinding。当我调用该方法时,它一直返回异常:

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

var endPoint = new EndpointAddress("https://xxxxx/v2_soap/index/");

var binding = new BasicHttpBinding
{
    Name = "HandlerBinding",
        CloseTimeout = TimeSpan.FromMinutes(1.0),
        HostNameComparisonMode = HostNameComparisonMode.StrongWildcard,
        MessageEncoding = WSMessageEncoding.Text,
        MaxReceivedMessageSize = 65536000,
        MaxBufferPoolSize = 65536000,
        UseDefaultWebProxy = true,
        AllowCookies = false,
        BypassProxyOnLocal = false,
        Security =
    {
        Mode =BasicHttpSecurityMode.Transport,
        Transport =
        {
            ClientCredentialType = HttpClientCredentialType.None,
            ProxyCredentialType = HttpProxyCredentialType.None
        },
        Message =
            {
                ClientCredentialType = BasicHttpMessageCredentialType.UserName
            }
    } 
};

以上设置与VS添加服务引用时生成的app.config完全相同:

 <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="HandlerBinding" closeTimeout="00:01:00"
          openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
          allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
          maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
          messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
          useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="Transport">
            <transport clientCredentialType="None" proxyCredentialType="None"
              realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="https://xxxxx/v2_soap/index/?SID=qttkobaa5jrmaj22il8mn9n342"
        binding="basicHttpBinding" bindingConfiguration="HandlerBinding"
        contract="HandlerPortType"
        name="HandlerPort" />
    </client>
  </system.serviceModel>

我什至尝试从 basichttpbinding 更改为 WSHttpBinding,但仍然没有运气。

4

1 回答 1

1

CodeProject 上有一篇很好的文章:SSL for self hosting WCF service

于 2012-07-19T14:51:53.190 回答