我已经遍布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,但仍然没有运气。