【发布时间】:2017-03-30 04:43:57
【问题描述】:
我已经用 WSDL 文件添加了 ServiceReference, 客户端抛出错误:
找不到名称为“Endpoint1”和合同的端点元素 ServiceModel 客户端配置中的“ServiceReference.IService” 部分。这可能是因为找不到配置文件 您的应用程序,或者因为没有匹配此名称的端点元素 可以在客户端元素中找到。
我不确定为什么 app.config 端点没有被拾取?
app.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="wsHttpPoint">
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="None" />
<message clientCredentialType="UserName" establishSecurityContext="false" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="https://example.com:5555/Service.svc"
binding="wsHttpBinding" bindingConfiguration="wsHttpPoint" contract="ServiceReference.IService"
name="Endpoint1" />
</client>
</system.serviceModel>
</configuration>
手动创建代理:
WSHttpBinding binding = new WSHttpBinding();
binding.Security.Mode = SecurityMode.Transport;
EndpointAddress address = new EndpointAddress("https://example.com:5555/Service.svc");
Client.ClientCredentials.UserName.UserName = "";
Client.ClientCredentials.UserName.Password = "";
Client = new ConnectionServiceClient(binding, address);
现在出现新错误:
connectionSecure 通道无法打开,因为与远程端点的安全协商失败。这可能是由于用于创建通道的 EndpointAddress 中缺少或错误指定了 EndpointIdentity。请验证 EndpointAddress 指定或暗示的 EndpointIdentity 是否正确标识了远程端点。
我是否正确设置了绑定? 我看到的每一篇文章都在谈论 basichttpBinding,是否有任何用于安全传输的 wsHttpbinding 示例?
【问题讨论】:
-
生成的 app.config 与正在执行的程序集是否在不同的项目中?
-
在同一个项目中