简体   繁体   English

带有axis2和Maven的Web服务

[英]Web Service with axis2 and Maven

i have to create a web service in eclipse using axis2 and Maven, but i have many problems. 我必须使用axis2和Maven在eclipse中创建Web服务,但是我有很多问题。 This is pom.xml: 这是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 gives me this error: Description Resource Path Location Type Plugin execution not covered by lifecycle configuration: 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 Problem Eclipse给了我这个错误:描述资源路径位置类型生命周期配置未涵盖插件执行:org.apache.axis2:axis2-java2wsdl-maven-plugin:1.5.4:java2wsdl(执行:默认值,阶段:进程类)pom .xml / MavenAxis2WS第20行Maven项目构建生命周期映射问题

If i write on command line mvn package and mvn process-classes, eclipse generates the wsdl file, but it is empty. 如果我在命令行mvn包和mvn进程类上编写,则eclipse会生成wsdl文件,但它为空。 I can't to create a web service. 我无法创建Web服务。 Please help me. 请帮我。 I need a complete example in which every step is completly described. 我需要一个完整的示例,其中完整描述了每个步骤。 I need to create a project with this folders: src/main/java. 我需要使用以下文件夹创建一个项目:src / main / java。 I hope someone can help me !! 我希望有一个人可以帮助我 !!

Thanks !!!! 谢谢 !!!!

Edit: 编辑:

if i remove process-classes obtain this error: Description Resource Path Location Type Plugin execution not covered by lifecycle configuration: 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 Problem. 如果我删除流程类,则会出现此错误:说明资源路径位置类型生命周期配置未涵盖插件执行:org.apache.axis2:axis2-java2wsdl-maven-plugin:1.5.4:java2wsdl(执行:默认,阶段:流程-classes)pom.xml / MavenAxis2WS第20行Maven项目构建生命周期映射问题。 If i remove 如果我删除

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

i haven't any errors but eclipse doesn't create wsdl when i run mvn package or mvn process-classes. 我没有任何错误,但是当我运行mvn包或mvn进程类时,eclipse不会创建wsdl。

MavenAxis2WebService class is: 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;
  }
}

when I try to run http://localhost:8080/MavenAxis2WS/services/MavenAxis2WebService?wsdl obtain HTTP Status 500 - javax.servlet.ServletException: org.apache.axis2.deployment.DeploymentException: org/apache/commons/httpclient/HttpException. 当我尝试运行http:// localhost:8080 / MavenAxis2WS / services / MavenAxis2WebService?wsdl时获得HTTP状态500-javax.servlet.ServletException:org.apache.axis2.deployment.DeploymentException:org / apache / commons / httpclient / HttpException 。 I post web.xml 我发布了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>

On this blog you can learn how to make a client part, so you have the wsdl and try to communicate with an existing server http://briansjavablog.blogspot.fr/2013/01/axis2-web-service-client-tutorial.html . 在此博客上,您可以学习如何制作客户端部件,以便拥有wsdl并尝试与现有服务器进行通信http://briansjavablog.blogspot.fr/2013/01/axis2-web-service-client-tutorial。 html

On this one, you have nothing, you will be the server http://sunnyratra.me/tag/apache-axis2-maven-example/ 在这一点上,您什么都没有,您将成为服务器http://sunnyratra.me/tag/apache-axis2-maven-example/

There are simple but complete examples, hope this help 有简单但完整的示例,希望对您有所帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM