WCF 出错的解决方法

1. 运行self-hosting之后报错:

                System.ServiceModel.AddressAccessDeniedException' occurred in System.Servic 

                System.ServiceModel.AddressAccessDeniedException: ... http://+:9999/calculatorService/...

以管理员权限运行cmd,解决HTTP名字空间保护的问题。打开了cmd之后,运行

"netsh http add urlacl http://+:9999/calculatorService/ user=everyone"

2. 

    System.ServiceModel.CommunicationObjectFaultedException

    The communication object, System.ServiceModel.ServiceHost, cannot be used for communication 

并且查看stack 中显示 timeout,猜想估计是权限不够,重启vs,右击选择属性->兼容性->以管理员身份运行。 

成功

3.

'System.ServiceModel.Security.SecurityNegotiationException' occurred in mscorlib.dll

Additional information: SOAP security negotiation with 'http://xlt1159-cn1:9999/messageService' for target 'http://xlt1159-cn1:9999/messageService' failed. See inner exception for more details.

问题:WCF的安全问题,如果不需要考虑安全性,最简单的方法将security.mode 设置为Node。

        如在service中添加代码:

                WSHttpBinding wsb = new WSHttpBinding();

                wsb.Name = "TestBinding";

                wsb.Security.Mode = SecurityMode.None;

        在 client中添加代码:   

                WSHttpBinding wsb = new WSHttpBinding();    

                wsb.Name = "TestBinding";

                wsb.Security.Mode = SecurityMode.None;

                wsb.Security.Message.ClientCredentialType = MessageCredentialType.None;

(https://msdn.microsoft.com/en-us/library/ms731925.aspx)

4.     WCF服务端如果是remote的,需要在服务端要打开端口号,在防火墙中新增规则。



转载于:https://my.oschina.net/u/2368952/blog/471081

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值