[英]WCF wsHttpBinding Client Certificate Authentication without using store in client
[英]Programatically Creating Wcf client with WsHttpBinding
我已使用WSDL文件添加ServiceReference,客户端抛出错误:
在ServiceModel客户端配置部分中找不到名称为'Endpoint1'且合同为'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中,客户端需要知道服务器以哪个帐户运行。 只需添加:
<endpoint address="https://example.com:5555/Service.svc"
binding="wsHttpBinding" bindingConfiguration="wsHttpPoint" contract="ServiceReference.IService"
name="Endpoint1">
<identity>
<userPrincipalName value="AccountName@domain" />
</identity>
</endpoint>
另外,可能需要将使用的端口注册给执行服务的用户。 以管理员身份打开“开发人员命令提示符”,然后运行:
netsh http add urlacl url=http://+:{Port}/ user={Domain\User}
根据您的需要交换{}
的值。 这只能运行一次。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.