【问题标题】:Is it common practice to specify security policy info in the WSDL?在 WSDL 中指定安全策略信息是常见的做法吗?
【发布时间】:2010-07-02 16:27:46
【问题描述】:

我们的团队正在使用 Spring-WS 和 XWSS 实现基于 SOAP 的 Web 服务。到目前为止,我们一直依赖 Spring-WS 从我们的 XSD 生成 WSDL。我们现在正在考虑是使用 WS-SecurityPolicy 在 WSDL 中记录安全需求,还是在单独的文档中传达它们。以下是我们正在思考的问题:

  • 标准是什么?将策略放在 WSDL 中是否常见?

  • 是否有许多(任何?)客户端生成器在 WSDL 中获取 WS-SecurityPolicy 信息?

  • Spring-WS 在生成 WSDL 时不支持 WS-SecurityPolicy。改用 Apache CXF 对我们有帮助吗?

此外,我们知道 REST 越来越受欢迎,但 SOAP 已被当权者指定。谢谢!

【问题讨论】:

    标签: web-services ws-security spring-ws


    【解决方案1】:

    希望这仍然可以帮助任何人。

    什么是标准?是不是很常见 WSDL 中的策略?

    是的,这很常见。

    是否有很多(任何?)客户端生成器选择 在 WSDL 中添加 WS-SecurityPolicy 信息?

    我知道的不多,我使用 Metro,它确实会根据安全约束生成客户端。

    【讨论】:

      【解决方案2】:

      所以这是你可以做的,而且很简单:

      1) 在您的项目中包含 cxf-bundle 库。如果你使用的是 maven,你可以这样做:

      <dependency>
          <groupId>org.apache.cxf</groupId>
          <artifactId>cxf-bundle</artifactId>
          <version>2.7.18</version>
      </dependency>
      

      2) 阅读here如何从wsdl生成java类。

      3) 确保在 pom 文件中,指向正确的 wsdlLocation 以从 wsdl 生成 java 文件。

      4) 初始化您生成的客户端并注入提供给您的用户名和密码。像这样的:

      final YourService service = new YourService();
      final YourStub stub = service.getService();
      
      final Map ctx = ((BindingProvider)stub).getRequestContext();
      
      ctx.put("ws-security.username", userName);
      ctx.put("ws-security.password", password);
      
      stub.callYourMethod();
      

      PS:请确保您拥有正确的库,我只使用了 cxf-bundle 并没有使用 cxf 中的其他任何东西,它确实有效!早些时候它不起作用,因为我单独包含了来自 cxf 的库。

      希望有帮助!!

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-08-28
        • 2015-10-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-07-14
        相关资源
        最近更新 更多