错误页面"未找到"当cxf-spring启动集成测试时

时间:2016-11-03 16:11:28

标签: spring maven soap spring-boot cxf

我正在尝试使用Apache CXF和Spring启动第一次开发soap jax-ws Web服务;我真的没有使用这些技术。为此,我创建了一个Web应用程序类型maven项目,旨在实现我的Web层服务(知道dao层和专业将通过成瘾来调用,实际上是一个带有spring boot的项目maven java应用程序)。并且所有这些都耦合在企业应用程序中。

然后我在web项目中构建了Apache cxf和spring boot,就像这样,我的pom.xml:

  

com.xxx.dev       模块网       0.0.1-SNAPSHOT       战争                  $ {} project.build.directory /批准           UTF-8       

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.apache.tomcat.embed</groupId>
                <artifactId>tomcat-embed-core</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.apache.tomcat.embed</groupId>
                <artifactId>tomcat-embed-websocket</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-tomcat</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-frontend-jaxws</artifactId>
        <version>3.1.7</version>
        <scope>provided</scope>
        <exclusions>
            <exclusion>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-core</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-rt-bindings-soap</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-rt-bindings-xml</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-transports-http</artifactId>
        <version>3.1.7</version>
        <scope>provided</scope>
        <exclusions>
            <exclusion>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-core</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
    </dependency>
    <dependency>
        <groupId>${project.groupId}</groupId>
        <artifactId>mobilepayment-dao</artifactId>
        <version>${project.version}</version>
    </dependency>
         <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-bindings-xml</artifactId>
        <version>3.1.7</version>
        <scope>provided</scope>
    </dependency>
       <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-bindings-soap</artifactId>
        <version>3.1.7</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-core</artifactId>
        <version>3.1.7</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-web-api</artifactId>
        <version>7.0</version>
        <scope>provided</scope>
    </dependency>
</dependencies>


<repositories>
    <repository>
        <id>mavencentral</id>
        <name>Maven Central</name>
        <url>https://repo1.maven.org/maven2/</url>
        <layout>default</layout>
    </repository>
</repositories>


<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
                <compilerArguments>
                    <endorseddirs>${endorsed.dir}</endorseddirs>
                </compilerArguments>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.6</version>
            <executions>
                <execution>
                    <phase>validate</phase>
                    <goals>
                        <goal>copy</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${endorsed.dir}</outputDirectory>
                        <silent>true</silent>
                        <artifactItems>
                            <artifactItem>
                                <groupId>javax</groupId>
                                <artifactId>javaee-endorsed-api</artifactId>
                                <version>7.0</version>
                                <type>jar</type>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

我的春季启动配置类:

  

@Configuration   @ImportResource({&#34;类路径:CXF-servlet.xml中&#34;})   公共课MyConfig {

@Autowired(required=true)
private Bus bus;

@Bean
public ServletRegistrationBean cxfServlet() {
    ServletRegistrationBean servlet = new ServletRegistrationBean(new CXFServlet(), "/services/*");
    servlet.setLoadOnStartup(1);
    return servlet;
}

@Bean
public IServicesWeb momoService() {
    return new MomoServices();
}

@Bean
public Endpoint endpoint() {
    EndpointImpl endpoint = new EndpointImpl(bus, momoService());
    endpoint.publish("/momo");
    return endpoint;
} }

网络服务界面:

  

@WebService public interface IServicesWeb扩展了IMetierGestionCompte

实施类:

  

@Component   @网络服务   公共类MomoServices实现了IServicesWeb {

private IMetierGestionCompte gcMetier;

public void setGcMetier(MetierImplGestionCompte gcMetier) {
    this.gcMetier = gcMetier;
}

@WebMethod
@Override
public void ajouterCompte( ) {
    gcMetier.ajouterCompte( );
}

Web项目在Wildfly上的部署非常好,有一个&#34; hello world&#34; at&#34; http:// localhost:8080 / web-mobilepayment /&#34;

我担心的是,当我尝试检查我的网络服务和地址wsdl:&#34; http:// localhost:8080 / web-mobilepayment / services&#34;和&#34; http:// localhost:8080 / web-mobilepayment / services? wsdl&#34;如果它不是消息,则不会出现任何内容(没有集成cxf-spring引导的跟踪)&#34;找不到&#34; 我不明白为什么我的网络服务不起作用,请帮助我!

1 个答案:

答案 0 :(得分:0)

您的“hello world”由您的网络servlet显示在web-mobilepayment下。如果要访问webservices,则必须使用/services/下的CXF servlet路径。

您使用momo路径发布了您的网络服务,因此您必须致电http://localhost: 8080/services/momo?wsdl