找不到对url的观察者的请求

oo7oh9g9  于 2021-07-06  发布在  Java
关注(0)|答案(0)|浏览(250)

我正在使用springboot+apachecxf和maven构建我的第一个soap应用程序。
我遵循了以下指南:https://www.baeldung.com/apache-cxf-with-spring
没有使用xml文件,所以最后我有了这些类:
演示应用程序

@SpringBootApplication
public class DemoApplication{

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }

}

serviceconfiguration@configuration公共类serviceconfiguration{

@Bean(name = Bus.DEFAULT_BUS_ID)
    public SpringBus springBus() {
        ServletDestinationFactory destinationFactory = new ServletDestinationFactory();
        SpringBus bus = new SpringBus();
        bus.setExtension(destinationFactory, HttpDestinationFactory.class);
        return bus;

    }

    @Bean
    public Endpoint endpoint() {
        EndpointImpl endpoint = new EndpointImpl(springBus(), new BaeldungImpl());
        endpoint.publish("http://localhost:8080/demo-0.0.1-SNAPSHOT");
        return endpoint;
    }
}

应用程序初始值设定项

public class AppInitializer implements WebApplicationInitializer {

    @Override
    public void onStartup(ServletContext container) {

        AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
        context.register(ServiceConfiguration.class);

        container.addListener(new ContextLoaderListener(context));

        ServletRegistration.Dynamic dispatcher = container.addServlet("dispatcher", new CXFServlet());
        dispatcher.addMapping("/services/*");
    }
}

贝尔登普勒

@WebService(endpointInterface = "com.example.demo.Baeldung")
public class BaeldungImpl  implements Baeldung {
    private int counter;

    @Override
    public String hello(String name) {
        return "Hello " + name + "!";
    }

    @Override
    public String register(Student student) {
        counter++;
        return student.getName() + " is registered student number " + counter;
    }

    @Override
    public String ProvaServizio() {
        return "";
    }

}

巴东

@WebService
public interface Baeldung {
    public String hello(String name);

    public String register(Student student);

    public String ProvaServizio();
}

学生

public class Student {
    private String name;

    Student() {
    }

    public Student(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}

在tomcat上构建和部署之后,遵循以下url,我得到以下内容:可用的soap服务:
如果我尝试更进一步(添加/hello、/hegister或/provaservizio),则会出现以下错误:
找不到服务。
日志上写着:

15:48:19.416 [http-nio-8080-exec-127] WARN org.apache.cxf.transport.servlet.ServletController - Can't find the request for http://localhost:8080/demo-0.0.1-SNAPSHOT/services/hello's Observer

这是我的pom

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.4.0</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
    <name>demo</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-frontend-jaxws</artifactId>
            <version>3.4.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-transports-http</artifactId>
            <version>3.4.1</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题