WCF出错怎么办
这篇文章主要介绍了WCF出错怎么办,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。
创新互联主要从事网站建设、成都网站建设、网页设计、企业做网站、公司建网站等业务。立足成都服务扶绥,10余年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:18982081108
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的,需要在服务端要打开端口号,在防火墙中新增规则。
感谢你能够认真阅读完这篇文章,希望小编分享的“WCF出错怎么办”这篇文章对大家有帮助,同时也希望大家多多支持创新互联,关注创新互联行业资讯频道,更多相关知识等着你来学习!
分享题目:WCF出错怎么办
分享地址:http://scyanting.com/article/jjogjh.html