Why doesn't the wsdl schema open via localhost if you use docker?

Viewed 24

I'm trying to make a soap service together with docker:

Dockerfile

FROM openjdk:11
COPY build/libs/testProject-0.0.1-SNAPSHOT.jar soap-user-control.jar
CMD ["java","-jar","soap-user-control.jar"]

docker-compose

version: '2'

services:
  app:
    image: 'docker-spring-boot-postgres:latest'
    build:
      context: .
    container_name: app
    depends_on:
      - db
    environment:
      - SPRING_DATASOURCE_URL=jdbc:postgresql://db:5432/compose-postgres
      - SPRING_DATASOURCE_USERNAME=compose-postgres
      - SPRING_DATASOURCE_PASSWORD=compose-postgres
      - SPRING_JPA_HIBERNATE_DDL_AUTO=update

  db:
    image: 'postgres:13.1-alpine'
    container_name: db
    environment:
      - POSTGRES_USER=compose-postgres
      - POSTGRES_PASSWORD=compose-postgres

Docker starts normally and saves the data to the database. i have xsd scheme:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://example.soap.com/api/users-web-service"
           targetNamespace="http://example.soap.com/api/users-web-service" elementFormDefault="qualified">

    <xs:complexType name="userInfo">
        <xs:sequence>
            <xs:element name="login" type="xs:string" />
            <xs:element name="name" type="xs:string" />
            <xs:element name="password" type="xs:string" />
            <xs:element name="userRole" type="tns:userRole" />
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="userRole">
        <xs:sequence>
            <xs:element name="id" type="xs:long" />
            <xs:element name="role" type="xs:string" />
        </xs:sequence>
    </xs:complexType>

    <xs:element name="addUSerRequest">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="userInfo" type="tns:userInfo" />
            </xs:sequence>
        </xs:complexType>
    </xs:element>

    <xs:element name="addUserResponse">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="userInfo" type="tns:userInfo" />
            </xs:sequence>
        </xs:complexType>
    </xs:element>

</xs:schema>

And the configuration class :

@EnableWs
@Configuration
public class WebServiceConfiguration extends WsConfigurerAdapter {

    @Bean
    public ServletRegistrationBean<MessageDispatcherServlet> messageDispatcherServlet(ApplicationContext applicationContext) {
        MessageDispatcherServlet servlet = new MessageDispatcherServlet();
        servlet.setApplicationContext(applicationContext);
        servlet.setTransformWsdlLocations(true);
        return new ServletRegistrationBean<>(servlet, "/api/*");
    }

    @Bean(name = "users")
    public DefaultWsdl11Definition defaultWsdl11Definition(XsdSchema usersSchema) {
        DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition();
        wsdl11Definition.setPortTypeName("userSoapHttp");
        wsdl11Definition.setLocationUri("/api");
        wsdl11Definition.setTargetNamespace("http://example.soap.com/api/users-web-service");
        wsdl11Definition.setSchema(usersSchema);
        return wsdl11Definition;
    }

    @Bean
    public XsdSchema usersSchema() {
        return new SimpleXsdSchema(new ClassPathResource("users.xsd"));
    }

}

The first time I'm trying to make a sopa service and I do it according to the guide. As I understand it after launching at http://localhost:8080/api/users.xsd

I have to get a sche in response. But I get ERR_CONNECTION_REFUSED

And I don't understand what the mistake is.Something is wrong with the docker or there is an error in the program.Ie why localhost is not working. At startup, it is written that the server started on port 8080, but the error comes out. I will be glad of help to understand what is wrong

I created the same program separately without docker and database and everything works.

1 Answers
Related