title: Spring WS integration test no endpoint mapping found
body: <p>I am trying to create a Web service with Spring WS. I followed their guide and i set up everything fine. When i run my application and send SOAP requests to the endpoint i get the right response. (I created a SOAP client with Spring WS too). So i got that going.</p>
  
  <p>Now i want to write tests. I got a unit test testing the method for the endpoint. All good and green. Right return value and such. Now i also want an integration test. This is where it goes wrong. I get the error: <code>WARN org.springframework.ws.server.EndpointNotFound - No endpoint mapping found for [SaajSoapMessage {http://my.app/soap/version}GetServiceVersionRequest]</code> (Had to censor some variables and naming for reasons. Could be they don't match. I will fix it if it occurs. In the real situation it works.)</p>
  
  <p>I have the following configuration:</p>
  
  <pre><code>@EnableWs
  @Configuration
  public class WebServiceConfig {
  
      @Bean
      public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext) {
          MessageDispatcherServlet servlet = new MessageDispatcherServlet();
          servlet.setApplicationContext(applicationContext);
          servlet.setTransformWsdlLocations(true);
          return new ServletRegistrationBean(servlet, "/ws/*");
      }
  
      @Bean(name = "serviceVersion")
      public DefaultWsdl11Definition defaultWsdl11Definition(XsdSchema serviceVersionSchema) {
          DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition();
          wsdl11Definition.setPortTypeName("ServiceVersionPort");
          wsdl11Definition.setLocationUri("/ws/version");
          wsdl11Definition.setTargetNamespace("http://my.app/soap/version");
          wsdl11Definition.setSchema(serviceVersionSchema);
          return wsdl11Definition;
      }
  
      @Bean
      public XsdSchema serviceVersionSchema() {
          return new SimpleXsdSchema(new ClassPathResource("xsd/ServiceVersionRequest.xsd"));
      }
  }
  </code></pre>
  
  <p>I have the following endpoint:</p>
  
  <pre><code>@Endpoint
  public class GetServiceVersionEndpoint {
  
      @PayloadRoot(namespace = "http://my.app/soap/version", localPart = "GetServiceVersionRequest")
      @ResponsePayload
      public JAXBElement&lt;GetServiceVersionResponse&gt; getServiceVersion(@RequestPayload GetServiceVersionRequest request) {
          GetServiceVersionResponse response = new GetServiceVersionResponse();
          ServiceVersion serviceVersion = new ServiceVersion();
          serviceVersion.setMajor(1);
          serviceVersion.setMinor(0);
          serviceVersion.setRevision(0);
          serviceVersion.setBuild(1);
          response.setVersion(serviceVersion);
          return new ObjectFactory().createGetServiceVersionResponse(response);
      }
  
  }
  </code></pre>
  
  <p>This is my test:</p>
  
  <pre><code>@RunWith(SpringJUnit4ClassRunner.class)
  @ContextConfiguration(classes = WebServiceConfig.class)
  public class GetServiceVersionEndpointIntegrationTest {
  
      @Inject
      private ApplicationContext applicationContext;
  
      private MockWebServiceClient mockClient;
  
      @Before
      public void init(){
          mockClient = MockWebServiceClient.createClient(applicationContext);
      }
  
      @Test
      public void testValidServiceVersionRequest() throws Exception {
  
          JAXBElement&lt;GetServiceVersionRequest&gt; request = new ObjectFactory().createGetServiceVersionRequest(new GetServiceVersionRequest());
  
          ServiceVersion serviceVersion = new ServiceVersion();
          serviceVersion.setMajor(1);
          serviceVersion.setMinor(0);
          serviceVersion.setRevision(0);
          serviceVersion.setBuild(1);
          GetServiceVersionResponse getServiceVersionResponse = new GetServiceVersionResponse();
          getServiceVersionResponse.setVersion(serviceVersion);
  
          JAXBElement&lt;GetServiceVersionResponse&gt; response = new ObjectFactory().createGetServiceVersionResponse(getServiceVersionResponse);
  
          mockClient
              .sendRequest(withPayload(new JAXBSource(JAXBContext.newInstance(GetServiceVersionRequest.class), request)))
              .andExpect(payload(new JAXBSource(JAXBContext.newInstance(GetServiceVersionResponse.class), response)));
  
      }
  }
  </code></pre>
  
  <p>The stacktrace is:</p>
  
  <pre><code>java.lang.AssertionError: No endpoint can be found for request [SaajSoapMessage {http://my.app/soap/version}GetServiceVersionRequest]
  
      at org.springframework.ws.test.support.AssertionErrors.fail(AssertionErrors.java:39)
      at org.springframework.ws.test.server.MockWebServiceClient.sendRequest(MockWebServiceClient.java:184)
      at nl.app.endpoint.GetServiceVersionEndpointIntegrationTest.testValidServiceVersionRequest(GetServiceVersionEndpointIntegrationTest.java:78)
  </code></pre>
  
  <p>I also tried sending a <code>Source</code> object with a raw XML SOAP request as content. Same error. I don't know what i am doing wrong as it works when running the application. Any idea's?</p>