title: Spring Boot publish REST & SOAP parallel
body: <p>I can't connect to my SOAP-Service listening on Port 9000 running a Spring-Boot application. The application is run in a docker container. The problem is that the soap-endpoint is listening on localhost instead of 0.0.0.0.</p>
  
  <p><strong>I want to bind the soap services on 0.0.0.0:9000 not 127.0.0.1:9000. How can I accomplish this?</strong></p>
  
  <p>Here my Setup:</p>
  
  <pre><code>Application.properties
  soap.url = http://localhost:9000/
  rest.url = http://localhost:9090/
  server.port = 9090
  </code></pre>
  
  <p>Spring-boot starts up correctly </p>
  
  <pre><code>Springboot-Startup-log
  2017-05-04 06:36:53.095  INFO 1 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 9090 (http)
  2017-05-04 06:36:53.110  INFO 1 --- [           main] ch.gemdat.Application                    : Started Application in 28.285 seconds (JVM running for 29.465)
  2017-05-04 06:36:55.387  INFO 1 --- [           main] myapp                                    : - services/soap/form/call/v1
  2017-05-04 06:36:55.388  INFO 1 --- [           main] myapp                                    : &gt;&gt; myapp successfully started in 0:31 &lt;&lt;
  </code></pre>
  
  <p>The tomcat (rest-services) started and listens to port 9090 default on interface 0.0.0.0. The soap-services are bound to localhost:9000.</p>
  
  <pre><code>netstat -tulpn
  tcp        0      0 0.0.0.0:9090            0.0.0.0:*               LISTEN      1/java
  tcp        0      0 127.0.0.1:9000          0.0.0.0:*               LISTEN      1/java
  </code></pre>
  
  <p>I perfectly can connect to all services running on port 9090. Because they are listening correctly on 0.0.0.0. </p>
  
  <p>This is how I publish the soap-services:</p>
  
  <pre><code>private static void publishSoapServices() {
      MyAppLogger.info("Register soap endpoints...");
      BeanDefinitionRegistry beanDefRegistry = new SimpleBeanDefinitionRegistry();
      ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(beanDefRegistry);
      scanner.addIncludeFilter(new AssignableTypeFilter(MyAppService.class));
      scanner.scan(Constants.SOAP_PACKAGE);
  
      for (String bean : beanDefRegistry.getBeanDefinitionNames()) {
          if (!bean.contains("springframework")) {
              try {
                  Class&lt;?&gt; soapClass = Class.forName(beanDefRegistry.getBeanDefinition(bean).getBeanClassName());
                  if (MyAppSoapService.class.isAssignableFrom(soapClass)) {
                      MyAppService soapService = (MyAppService) soapClass.newInstance();
                      Endpoint.publish(PropertyReader.getValue("soap.url") + soapService.getEndpoint(), soapService);
                      ctx.getAutowireCapableBeanFactory().autowireBean(soapService);
                      MyAppLogger.info("- " + soapService.getEndpoint());
                  }
              } catch (Exception e) {
                  MyAppLogger.error("Soap service ''{0}'' could not be published.", e, bean);
              }
          }
      }
  }
  </code></pre>
  
  <p>All services are available on localhost. Means <code>http://localhost:9000/services/soap/form/call/v1</code> works. But when I run it in a docker container (run-arguments: -p 9000:9000 -p 9090:9090) only the rest-services are available (because they only listen to localhost... and rest-services listens to all ips(0.0.0.0))</p>
  
  <p>Docker inspect shows that the port is mapped correctly:</p>
  
  <pre><code>"Ports": {
              "9000/tcp": [
                  {
                      "HostIp": "0.0.0.0",
                      "HostPort": "9000"
                  }
              ]
  </code></pre>