简体   繁体   中英

Web Service with axis2 and Maven

i have to create a web service in eclipse using axis2 and Maven, but i have many problems. This is 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

If i write on command line mvn package and mvn process-classes, eclipse generates the wsdl file, but it is empty. I can't to create a web service. 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. 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. 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.

MavenAxis2WebService class is:

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. I post 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 .

On this one, you have nothing, you will be the server http://sunnyratra.me/tag/apache-axis2-maven-example/

There are simple but complete examples, hope this help

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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