Announcement Announcement Module
Collapse
No announcement yet.
Integration Testing of secure Spring Web Service Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Integration Testing of secure Spring Web Service

    I am trying to write server side integration tests of my Spring Web Service Endpoint secured using - Spring WS Security 2.1.2.RELEASE and - WSS4j 1.6.9. I am trying to follow Spring documentation http://static.springsource.org/sprin...ml/server.html. With the setup that I have got so far, I can send a request payload

    Code:
    <myns:MyRequest xmlns:myns="...">
            ...
    </myns:MyRequest>
    using MockWebServiceClient as
    Code:
    mockWebServiceClient.sendRequest(withPayload(requestPayload)).andExpect(clientOrSenderFault());
    which the integration test properly maps to the endpoint in the test context and I get a "Could not validate request: No WS-Security header found" error as expected.

    Problem: Now the problem here is if I send a request in a SOAP envelope with a security header and body, I would get an endpoint not found exception.
    Code:
    <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>
    since it will try to find an endpoint around "{http://schemas.xmlsoap.org/soap/envelope/}Envelope".

    Is there a way to work around this problem?

  • #2
    Have you looked at the javadocs of RequestCreators? Instead of withPayload use withSoapEnveloppe.

    Comment


    • #3
      That's what I was expecting but since I was using spring-ws-test-2.0.5.RELEASE, I didn't have that. I got that with upgrade to spring-ws-test-2.1.2.RELEASE.
      Thanks Marten for pointing that out.

      Comment

      Working...
      X