【问题标题】:Integration Testing of secure Spring Web Service安全 Spring Web Service 的集成测试
【发布时间】:2013-02-28 23:56:33
【问题描述】:

我正在尝试编写我的 Spring Web 服务端点的服务器端集成测试,使用安全 - Spring WS 安全 2.1.2.RELEASE 和 - WSS4j 1.6.9。 我正在尝试遵循 Spring 文档http://static.springsource.org/spring-ws/sites/2.0/reference/html/server.html。通过我目前的设置,我可以发送请求有效负载

<myns:MyRequest xmlns:myns="...">
        ...
</myns:MyRequest>

使用 MockWebServiceClient 作为

mockWebServiceClient.sendRequest(withPayload(requestPayload)).andExpect(clientOrSenderFault());

集成测试正确映射到测试上下文中的端点,并且我收到“无法验证请求:未找到 WS-Security 标头”错误,正如预期的那样。

问题:现在的问题是,如果我在带有安全标头和正文的 SOAP 信封中发送请求,我会得到一个未找到端点的异常。

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:myns="...">
   <soapenv:Header>
       ...
   </soapenv:Header>
   <soapenv:Body>
      <myns:MyRequest>
        ...
      </myns:MyRequest>
   </soapenv:Body>
</soapenv:Envelope>

因为它会尝试在“{http://schemas.xmlsoap.org/soap/envelope/}信封”周围找到一个端点。

有没有办法解决这个问题?

【问题讨论】:

  • Spring WS Test 2.1 的较新版本在 RequestCreaters 中添加了两种方法:RequestCreator withSoapEnvelope(Source soapEnvelope) 和 RequestCreator withSoapEnvelope(Resource soapEnvelope),我可以使用它们发送 SOAP 信封以进行集成测试。 forum.springsource.org/…

标签: integration-testing spring-ws ws-security


【解决方案1】:

Spring WS Test 2.1 的较新版本在 RequestCreaters 中添加了两个方法:RequestCreators.withSoapEnvelope(Source soapEnvelope) 和 RequestCreators.withSoapEnvelope(Resource soapEnvelope),它们允许发送 SOAP 信封以进行集成测试。 http://forum.springsource.org/showthread.php?135298-Integration-Testing-of-secure-Spring-Web-Service

【讨论】:

    猜你喜欢
    • 2011-10-22
    • 2016-08-04
    • 1970-01-01
    • 1970-01-01
    • 2012-08-21
    • 2017-03-17
    • 1970-01-01
    • 2018-05-17
    • 1970-01-01
    相关资源
    最近更新 更多