gpt4 book ai didi

java - 使用 axis2 和 Maven 的 Web 服务

转载 作者:行者123 更新时间:2023-12-01 11:51:44 27 4
gpt4 key购买 nike

我必须使用 axis2 和 Maven 在 Eclipse 中创建一个 Web 服务,但我有很多问题。这是pom.xml:

<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 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ratra.ws</groupId>
<artifactId>MavenAxis2WS</artifactId>
<packaging>war</packaging>
<version>1.0.0-SNAPSHOT</version>
<name>MavenAxis2WS</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-java2wsdl-maven-plugin</artifactId>
<version>1.5.4</version>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>java2wsdl</goal>
</goals>
</execution>
</executions>
<configuration>
<className>com.ratra.ws.MavenAxis2WS.MavenAxis2WebService</className>
<outputFileName>${project.build.directory}/MavenAxis2WebService.wsdl</outputFileName>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2</artifactId>
<version>1.5.4</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-http</artifactId>
<version>1.5.4</version>
<exclusions>
<exclusion>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-local</artifactId>
<version>1.5.4</version>
</dependency>
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>2.4.0</version>
<exclusions>
<exclusion>
<groupId>stax</groupId>
<artifactId>stax-api</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>

Eclipse 给我这个错误:描述资源路径位置类型生命周期配置未涵盖插件执行:org.apache.axis2:axis2-java2wsdl-maven-plugin:1.5.4:java2wsdl (execution:default,phase:process-classes) pom.xml/MavenAxis2WS line 20 Maven Project Build Lifecycle Mapping问题

如果我在命令行 mvn package 和 mvn process-classes 上写入,eclipse 会生成 wsdl 文件,但它是空的。我无法创建网络服务。请帮我。我需要一个完整的示例,其中完整描述了每个步骤。我需要使用以下文件夹创建一个项目:src/main/java。我希望有人能帮助我!!

谢谢!!!

编辑:

如果我删除进程类,则会出现此错误:描述资源路径位置类型生命周期配置未涵盖插件执行:org.apache.axis2:axis2-java2wsdl-maven-plugin:1.5.4:java2wsdl (execution:default,phase:process-classes) pom.xml/MavenAxis2WS line 20 Maven Project Build Lifecycle Mapping问题。如果我删除

<execution>
<goals>
<goal>java2wsdl</goal>
</goals>
</execution>
</executions>

我没有任何错误,但当我运行 mvn package 或 mvn process-classes 时,Eclipse 不会创建 wsdl。

MavenAxis2WebService 类是:

package com.ratra.ws.MavenAxis2WS;
public class MavenAxis2WebService {
public String ping(String text) {
if (text == null) {
return "Service is up and available";
}
return "Service is up and available, message: " + text;
}
}

当我尝试运行 http://localhost:8080/MavenAxis2WS/services/MavenAxis2WebService?wsdl 时获得HTTP 状态 500 - javax.servlet.ServletException:org.apache.axis2.deployment.DeploymentException:org/apache/commons/httpclient/HttpException。我发布 web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<display-name>MavenAxis2WS</display-name>
<servlet>
<servlet-name>AxisServlet</servlet-name>
<servlet-class>org.apache.axis2.transport.http.AxisServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
</web-app>

最佳答案

在此博客上,您可以学习如何制作客户端部分,以便您拥有 wsdl 并尝试与现有服务器进行通信 http://briansjavablog.blogspot.fr/2013/01/axis2-web-service-client-tutorial.html .

在这一点上,你什么都没有,你就是服务器http://sunnyratra.me/tag/apache-axis2-maven-example/

有简单但完整的示例,希望对您有所帮助

关于java - 使用 axis2 和 Maven 的 Web 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28762802/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com