c#-4.0 – 将WSSE SOAP标头添加到Web引用
发布时间:2020-12-15 07:42:31 所属栏目:百科 来源:网络整理
导读:我正在尝试将WSSE SOAP Header添加到我的服务调用中,但大多数示例都集中在WCF上.我没有使用WCF.我添加了一个Web引用(WSDL). 我尝试了各种方法但没有成功,比如 – 覆盖GetWebRequest方法: protected override System.Net.WebRequest GetWebRequest(Uri uri)
我正在尝试将WSSE SOAP Header添加到我的服务调用中,但大多数示例都集中在WCF上.我没有使用WCF.我添加了一个Web引用(WSDL).
我尝试了各种方法但没有成功,比如 – 覆盖GetWebRequest方法: protected override System.Net.WebRequest GetWebRequest(Uri uri) { string user = "username"; string pwd = "password"; System.Net.WebRequest request = base.GetWebRequest(uri); string auth = string.Format("Basic {0}",Convert.ToBase64String(System.Text.Encoding.Default.GetBytes(string.Format("{0}:{1}",user,pwd)))); request.PreAuthenticate = true; request.AuthenticationLevel = System.Net.Security.AuthenticationLevel.MutualAuthRequested; request.Headers.Add(HttpRequestHeader.Authorization,auth); return request; } WSSE安全标题应该类似于: <Security xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> <UsernameToken> <Username>username</Username> <Password>password</Password> </UsernameToken> </Security> 提前谢谢了! 解决方法
请参考以下内容:
http://underthehood.ironworks.com/2010/01/why-doesnt-my-generated-proxy-class-build-wsse-elements-into-the-soap-request-header.html Why doesn’t my generated proxy class build WSSE elements into the SOAP request header? How to add security header to a SOAP message? 哪个提供答案! (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
- Displays information relevant to flashback da
- ruby-on-rails – 如何在Solr Cell中使用最新版本
- c# – 使用图形api在Azure Active目录组中搜索用
- linq-to-xml – Linq to XML – 删除节点并在同一
- JSONArray类将JavaBean,List,Map转换成json字符串
- c – 使用std :: chrono将32位unix时间戳转换为s
- 这两个枚举[Flags]声明(C#)之间有什么区别
- unit-testing – 在Node中模拟依赖项
- ajax post 与get方法 data写法
- NodeJS 工程师必备的 8 个工具
热点阅读