1 | initial version |
The process of configuring SOAP service testing with WebServiceServerTest and MockWebServiceClient in Java involves several steps:
Create a server-side JAX-WS annotated Java class or endpoint interface with methods to be tested. This class should be annotated with @WebService, @WebMethod, and @WebParam annotations.
Build the server side Java class or endpoint interface into a Java ARchive (JAR) file.
Create a JUnit test class for the server-side web service. Use the @RunWith annotation to specify that it runs with SpringJUnit4ClassRunner.class.
Use the @ContextConfiguration annotation to load the application context configuration file that specifies the endpoint interface class and other configuration settings.
Use the @WebServiceServerTest annotation to annotate the test class, specifying the endpoint interface class and the path of the WSDL file.
Inside the test class, write methods to test the server-side web service methods.
Create a MockWebServiceClient class to simulate the client-side of the web service. This class should be annotated with @WebServiceClient, @WebServiceRef, and @WebServiceTestClient annotations.
Use the @ContextConfiguration annotation to load the application context configuration file for the client-side test.
Use the @MockWebServiceClient annotation to specify the endpoint interface class, WSDL location, and endpoint URL.
Inside the client-side test class, write methods to simulate client-side requests and test the server-side web service response.
Run the JUnit test class to test the server-side and client-side web services.
Analyze the test results and debug any issues.