Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The process of configuring SOAP service testing with WebServiceServerTest and MockWebServiceClient in Java involves several steps:

  1. 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.

  2. Build the server side Java class or endpoint interface into a Java ARchive (JAR) file.

  3. Create a JUnit test class for the server-side web service. Use the @RunWith annotation to specify that it runs with SpringJUnit4ClassRunner.class.

  4. Use the @ContextConfiguration annotation to load the application context configuration file that specifies the endpoint interface class and other configuration settings.

  5. Use the @WebServiceServerTest annotation to annotate the test class, specifying the endpoint interface class and the path of the WSDL file.

  6. Inside the test class, write methods to test the server-side web service methods.

  7. Create a MockWebServiceClient class to simulate the client-side of the web service. This class should be annotated with @WebServiceClient, @WebServiceRef, and @WebServiceTestClient annotations.

  8. Use the @ContextConfiguration annotation to load the application context configuration file for the client-side test.

  9. Use the @MockWebServiceClient annotation to specify the endpoint interface class, WSDL location, and endpoint URL.

  10. Inside the client-side test class, write methods to simulate client-side requests and test the server-side web service response.

  11. Run the JUnit test class to test the server-side and client-side web services.

  12. Analyze the test results and debug any issues.