How to test a soap endpoint that returns soapfaultclientexception

139 Views Asked by At

I have a soap endpoint that returns fault message when passing some parameters. I need to validate the fault string and pass the test when fault string is returned.

  runner.soap(action -> action
                .client(testClient)
                .receive()
                .status(HttpStatus.INTERNAL_SERVER_ERROR)
                .validate("/t:soap:Fault/t:faultcode", "test"));

This above code gives me a soapfaultclientexception. I couldn't pass this test. Any idea.

1

There are 1 best solutions below

0
Christoph Deppisch On

Please use fault strategy=propagate on the soap client configuration. By default it uses throwException strategy. This is why you get the exception.

With propagate you should be able to verify the fault in a receive action.

Please refer to the documentation for the details.