在.NET 4.5 WCF不安全响应
问题说明
我工作的客户端应用程序使用SOAP的Web服务。新增SOAP Web服务作为服务的参考。它连接到IBM服务器和服务器需要WS-Security的基本认证方式。
I'm working on client application to utilize SOAP web service. Added SOAP web services as Service reference. It connects to IBM server and server requires WS-Security basic authentification.
调用方式的默认设置,并得到了一个错误(无认证头)
Called with default settings and got an error(no authentication header)
修改code看起来像这样:
Modified code to look like so:
var service = new RealTimeOnlineClient();
service.ClientCredentials.UserName.UserName = "xxxxx";
service.ClientCredentials.UserName.Password = "yyyyy";
现在,当我看着响应提琴手 - 工作正常(我从服务器获得预期的信封),我得到了正确的信封背面
Now when I look at response in Fiddler - works properly (I get expected envelope from server), I get proper envelope back.
不过,我从WCF异常:
However, I get exception from WCF:
安全处理器无法找到消息中的安全标头。这可能是因为消息是不安全的故障或因为通信双方之间具有约束力的不匹配。如果服务被配置为安全和客户端不使用安全性可以发生这种情况。
快速搜索和一堆这里答案那么点我从微软那里他们增加了新的属性,以修补程序 EnableUnsecuredResponse
。问题是 - 我想不出哪里该属性适用于我的code或配置。添加到web.config文件中的安全
标签不起作用(错误出来找不到属性)。
Quick search and bunch of answers here on SO points me to HotFix from Microsoft where they added new property EnableUnsecuredResponse
. Problem is - I can't figure out WHERE to apply this property in my code OR in config. Adding to security
tag in web.config doesn't work (errors out can't find property).
据我所知修复出来的.NET 3.5和2009-2010大多数问题。它应该是在4.5已,是否正确?这个属性我该如何申请到我的code?
I understand hotfix came out for .NET 3.5 and most questions from 2009-2010. It should be in 4.5 already, correct? How do I apply this property to my code?
正确答案
我不得不添加下面的code,以改变EnableUnsecureResponse
I had to add following code to alter value of "EnableUnsecureResponse"
var service = new RealTimeOnlineClient();
service.ClientCredentials.UserName.UserName = "xxxxx";
service.ClientCredentials.UserName.Password = "yyyyy";
var elements = service.Endpoint.Binding.CreateBindingElements();
elements.Find<SecurityBindingElement>().EnableUnsecuredResponse = true;
service.Endpoint.Binding = new CustomBinding(elements);
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /reply/detail/tanhcfhcjh
-
YouTube API 不能在 iOS (iPhone/iPad) 工作,但在桌面浏览器工作正常?
it1352 07-30 -
iPhone,一张图像叠加到另一张图像上以创建要保存的新图像?(水印)
it1352 07-17 -
保持在后台运行的 iPhone 应用程序完全可操作
it1352 07-25 -
使用 iPhone 进行移动设备管理
it1352 07-23 -
在android同时打开手电筒和前置摄像头
it1352 09-28 -
扫描 NFC 标签时是否可以启动应用程序?
it1352 08-02 -
检查邮件是否发送成功
it1352 07-25 -
Android微调工具-删除当前选择
it1352 06-20 -
Android App 和三星 Galaxy S4 不兼容
it1352 07-20 -
希伯来语的空格句子标记化错误
it1352 06-22