加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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?

哪个提供答案!

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读