【发布时间】:2011-11-16 05:12:30
【问题描述】:
在 C# 中,我试图访问位于 HTTPS 地址上的 Web 服务。我的代码是在一个类库中定义的,在主应用程序中使用 DLL 引用该类库 — 因此,使用 App.config 文件配置 Web 服务的标准方法在这里是不可能的。
我的代码基本上等于以下内容:
var remoteAddress = new System.ServiceModel.EndpointAddress(
"https://myUrl.com/Service.svc");
MyServiceClient myClient = new MyServiceClient(
new System.ServiceModel.WSHttpBinding(),
remoteAddress);
myClient.ClientCredentials.ClientCertificate.SetCertificate(
StoreLocation.CurrentUser,
StoreName.My,
X509FindType.FindByThumbprint,
"91 47 0b e8 80 bf ee 68 32 93 f0 d4 ee e6 14 8c e5 0c fa 3e"
);
myClient.Endpoint.Binding.SendTimeout = new TimeSpan(0, 0, 0, 10);
var myResult = myClient.MyMethod("foo bar");
但即使我使用 WSHttpBinding,我也会收到带有消息的 ArgumentException:
提供的 URI 方案“https”无效;预期为“http”。
参数名称:via
谁能找出问题所在?
【问题讨论】:
标签: c# .net wcf web-services https