Sohel Shaikh
Sohel Shaikh

Reputation: 47

how to test a REST web service that calls another SOAP web service in Spring Boot

I am currently working on Spring Boot. I am stuck with a problem: My REST service is calling SOAP service and I want to unit test my service whether the XML response from SOAP service matches the REST service response in JSON.

How can I achieve this?

Upvotes: 2

Views: 524

Answers (1)

jurez
jurez

Reputation: 4657

Usually you do such things with mocking. During the test, you inject a class that behaves exactly like the target SOAP service, but is hardcoded to return some predetermined value. See Mockito tutorial for example. In a nutshell, you tell Spring to inject a mocked bean into your service instead of the real one.

You can also mock the actual service, for example with something like Wiremock. In this case, you change the URL in Spring configuration to point to Wiremock instead of the actual service.

Upvotes: 3

Related Questions