title: Why web service and proxy client not connecting?
body: <p>I have an application where I try to combine <code>Spring MVC</code> and <code>Apache CFX</code>(soap) web services.  When I run just the app, everything seems fine, I see generated WSDL by this link(<code>http://localhost:8080/services/customer?wsdl</code>). But when I run tests, it throws <code>WebServiceException: Could not send Message</code>... <code>Connection refused</code>.</p>
  
  <p>I've opened all ports for public, private and domain area through <code>Windows Firewall Defender</code>. Maybe I've missed something.
  In a desperate attempt to investigate it, I've checked the link with this command (<code>wsimport -keep -verbose http://localhost:8080/services/customer?wsdl</code>). As a result, it gave this:</p>
  
  <pre><code>[ERROR] Server returned HTTP response code: 403 for URL: http://localhost:8080/services/customer?wsdl
  
  Failed to read the WSDL document: http://localhost:8080/services/customer?wsdl, because 1) could not find the document; /2) the document could not be read; 3) the root element of the document is not &lt;wsdl:definitions&gt;.
  
  
  [ERROR] Could not find wsdl:service in the provided WSDL(s):
  
   At least one WSDL with at least one service definition needs to be provided.
  
  Now I do not know which way to dig. 
  </code></pre>
  
  <p>WebServiceDispatcherServletInitializer</p>
  
  <pre><code>public class WebServiceDispatcherServletInitializer implements WebApplicationInitializer {
  
      @Override
      public void onStartup(ServletContext servletContext) throws ServletException {
          AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
          context.register(WebServiceConfig.class);
          servletContext.addListener(new ContextLoaderListener(context));
  
          ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcher", new CXFServlet());
          dispatcher.addMapping("/services/*");
      }
  }
  </code></pre>
  
  <p>WebServiceConfig</p>
  
  <pre><code>@Configuration
  public class WebServiceConfig {
  
      @Bean(name = Bus.DEFAULT_BUS_ID)
      public SpringBus springBus() {
          return new SpringBus();
      }
  
  
      @Bean
      public Endpoint endpoint() {
          EndpointImpl endpoint = new EndpointImpl(springBus(), new CustomerWebServiceImpl() );
          endpoint.publish("http://localhost:8080/services/customer");
          return endpoint;
      }
  }
  </code></pre>
  
  <p>ClientConfig</p>
  
  <pre><code>@Configuration
  public class ClientConfig {
  
      @Bean(name = "client")
      public Object generateProxy() {
          return proxyFactoryBean().create();
      }
  
      @Bean
      public JaxWsProxyFactoryBean proxyFactoryBean() {
          JaxWsProxyFactoryBean proxyFactory = new JaxWsProxyFactoryBean();
          proxyFactory.setServiceClass(CustomerWebService.class);
          proxyFactory.setAddress("http://localhost:8080/services/customer");
          return proxyFactory;
      }
  }
  </code></pre>
  
  <p>CustomerWebServiceImplTest</p>
  
  <pre><code>@ActiveProfiles(profiles = "test")
  @ContextConfiguration(classes = {
          PersistenceConfig.class,
          RootConfig.class,
          WebServiceConfig.class,
          ClientConfig.class
  })
  @WebAppConfiguration
  public class CustomerWebServiceImplTest {
  
      private ApplicationContext context = new AnnotationConfigApplicationContext(ClientConfig.class);
  
      private CustomerWebService customerWsProxy = (CustomerWebService) context.getBean("client");
  
      @Test
      public void addCustomer() {
          CustomerDto customer = new CustomerDto();
          customer.setName("John");
          assertEquals("Hello " + customer.getName(), customerWsProxy.addCustomer(customer));
      }
  }
  </code></pre>
  
  <p>Could you give a hint where the error might be?</p>
  
  <p><strong>UPD: I checked this setup on PC where I and my applications have full access rights and it still throws the Exception.</strong></p>