如何将安全标头添加到SOAP消息? [英] How to add security header to a SOAP message?

查看:125
本文介绍了如何将安全标头添加到SOAP消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用我们的提供商从C#应用中使用Java编写的Web服务。是时候进行通信了,我得到了:

I'm trying to consume a WebService written in Java by our provider from our C# App. When it's time to communicate, I get this:


WSDoAllReceiver:传入的消息不包含必需的安全标头

WSDoAllReceiver: Incoming message does not contain required Security header

从昨天开始,我试图找出如何向SOAP消息中添加安全标头。

Since yesterday I'm trying to find out how to add security header to a SOAP message.

是,我阅读了此内容(对如何创建SOAP毫无头绪< wsse:Security> ; header ),但它不起作用。

Yes, I read this ( Clueless about how to create SOAP <wsse:Security> header ) but it did not work.

我环顾四周,这似乎是一个相当疑问的问题。我想知道是否可以在这里获得一些帮助,一些指针,一些代码来使我入门。

I looked around and this seems to be a rather asked question. I wonder if I can get some help here, some pointers, some code, to get me started.

推荐答案

我实际上设法通过使用WSE来实现。有趣的是,提供商的Web服务不能与WSE 3.0一起使用,但是可以与WSE 2.0一起使用。以下是步骤

I actually managed to achieve that by using WSE. The funny thing is that the provider's Web Services would not work with WSE 3.0, but they did with WSE 2.0. Here are the steps


  • 获取 WSE 2.0

  • 将Web参考添加到项目中

  • 在Web参考代理实现中:

替换

public partial class UserWS : System.Web.Services.Protocols.SoapHttpClientProtocol

by

public partial class UserWS : Microsoft.Web.Services2.WebServicesClientProtocol




  • 调用Web服务之前:

  • 设置身份验证信息

    UsernameToken token = new UsernameToken("user", "pwd", PasswordOption.SendPlainText);
    yourProxy.RequestSoapContext.Security.Tokens.Add(token);
    

    就是这样!仅供参考,提供者是 Blackboard 实例。

    And that's it! FYI, the provider is a Blackboard instance.

    这篇关于如何将安全标头添加到SOAP消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆