C# 使用 Java SOAP 服务 WSSecurity

标签 c# java soap aes ws-security

我正在尝试使用基于 Java 的 Web 服务,但每次我尝试连接时都会收到这样的错误:

org.apache.ws.security.WSSecurityException: The security token could not be authenticated or authorized;

服务管理员说我应该发送他发给我的用 AES key 加密的密码。

这就是我的 web.config 到目前为止的内容

<client>
      <endpoint address="http://webservicer2:8088/billing/"
        binding="basicHttpBinding" bindingConfiguration="ServiceBill3"
        contract="ServiceBilling.ServiceBillingContract" name="ServiceBill3">
        <headers>
          <wsse:Security soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next"
            soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
            xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
            <wsse:UsernameToken wsu:Id="UsernameToken-1" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
              <wsse:Username>ohmygod</wsse:Username>
              <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">bbqsauce</wsse:Password>
            </wsse:UsernameToken>
          </wsse:Security>
        </headers>
      </endpoint>
    </client>

当我尝试对该服务执行任何方法时发生错误。我应该修改什么来添加我的 key ? 有人吗?

最佳答案

不要将 BasicHTTPBinding 与硬编码 header 一起使用。请改用 WCF 中内置的 WS-Security 支持。参见 http://msdn.microsoft.com/en-us/library/vstudio/ms731058(v=vs.90).aspx .此外,请查看使用服务 WSDL 时生成的配置。

关于C# 使用 Java SOAP 服务 WSSecurity,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13917831/

相关文章:

c# - 来自 WSDL 的 .NET 网络服务客户端

java - 使用 Java 8 中的 lambda 函数获取 ArrayList 的总数,根据日期分组

c# - SOAP Web服务/VS2010添加服务引用

ruby - 无法通过 HTTPS 将 SOAP 客户端 (savon) 连接到 SOAP Web 服务

python - 是否存在 Python 3 SOAP 客户端模块?

c# - 如何注册我的 visual studio 扩展来运行事件?

c# - 在 RavenDB 中处理带点的前缀

c# - 数据适配器有什么用

java - 将输入发送到 nmap 进程

java - 为不同环境定义 Spring bean 时的常用策略