通过互联网使用 wcf 服务
本文关键字:wcf 服务 互联网 | 更新日期: 2023-09-27 17:56:58
我有一个使用 WsHttpBinding 作为绑定的 wcf 服务。此服务托管在具有公共 IP 的服务器上。我需要通过互联网使用此 wcf 服务,但它给了我以下错误。
这里没有侦听 http://IP:9962/MyService 可以接受消息的端点。
任何帮助都非常感谢。
这是一个非标准的 HTTP 端口,所以我的第一个问题是 - 防火墙/路由问题?
我找到了答案。1-我需要在我正在使用的绑定上添加安全性。
binding.Security.Mode = SecurityMode.Message;
binding.Security.Message.ClientCredentialType = MessageCredentialType.UserName;
2-我需要在服务主机上添加自定义身份验证。
svh.Credentials.UserNameAuthentication.UserNamePasswordValidationMode = System.ServiceModel.Security.UserNamePasswordValidationMode.Custom;
People365UserNameValidator cs = new People365UserNameValidator();
svh.Credentials.UserNameAuthentication.CustomUserNamePasswordValidator = cs;
svh.Credentials.ServiceCertificate.SetCertificate(StoreLocation.LocalMachine,
StoreName.TrustedPeople, X509FindType.FindByIssuerName, "Certificate Name");
3-我需要在计算机的MMC中添加证书