1. 准备:创建一个Maven Web App 项目

这里让我们使用Maven 模板创建一个Web App 项目

1. New------> Maven Project

2. 使用默认配置,点击Next

3. Catelog 选择Internal ,Filter  输入webappp

4.输入组织Id 和包名点击下一步

5. 点击Finished 之后我们可以看到这样一个目录结构

注意:

红色报错是因为没有引入servlet-api.jar,我们稍后处理

由于这个模板文件比较陈旧,因此我们需要做个修改。

6.Package 视图下,项目右键——Build Path -----> Configure Build Path...

7. 切换到Libraries 视图,点击Remove ,移除这个陈旧的JRE 依赖类库

8.点击添加类库

9. 选中JRE System Library

10.选中工作空间默认的JRE,点击Finished ,关闭对话框。

11. 之后会自动变成这样的目录结构

Tips:

我们可以对比看到比之前多了两个文件夹

src/main/java

src/main/test 文件夹

12. 下载 Axis2.war 样例模板

http://axis.apache.org/axis2/java/core/download.html

13.下载后用好压将这个*.war 解压,

14. WEB-INF/lib 目录下有一些说明文件,我们需要删掉,只留下*.jar 即可

15.用命令行进入这个解压目录,我们需要删除所有的*.txt 文件,输入以下dos 命令即可

del *.txt

执行效果如下:

16. 我们可以看到所有的txt 文件已经被删掉了

17. 复制所有解压的文件到刚才创建的项目webapp 文件夹下

最后将WEB-INF/lib 下的jar 添加到build path 中就可以了。

当然也可以使用Maven 来管理,我花了点时间整理了下,贴出来

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.xingyun</groupId>
<artifactId>axis2-webapp-pojo-sample</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>axis2-webapp-pojo-sample Maven Webapp</name>
<url>http://maven.apache.org</url> <!-- 该项目支持Tomcat 7.0 + JDK1.8+ -->
<dependencies>
<!-- Axis2 Framework start -->
<!-- activation-1.1.jar -->
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>${activation.version}</version>
</dependency> <!-- antlr-2.7.7.jar https://mvnrepository.com/artifact/antlr/antlr -->
<dependency>
<groupId>antlr</groupId>
<artifactId>antlr</artifactId>
</dependency> <!-- apache-mime4j-core-0.7.2 https://mvnrepository.com/artifact/org.apache.james/apache-mime4j-core -->
<dependency>
<groupId>org.apache.james</groupId>
<artifactId>apache-mime4j-core</artifactId>
<version>${apache.mime4j.core.version}</version>
</dependency> <!-- axiom axiom-api-1.2.21.jar -->
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-api</artifactId>
<version>${axiom.version}</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency> <!-- axiom-dom-1.2.21.jar -->
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-dom</artifactId>
<version>${axiom.version}</version>
</dependency> <!-- axiom-impl-1.2.21.jar -->
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-impl</artifactId>
<version>${axiom.version}</version>
</dependency> <!-- axiom-jaxb-1.2.21.jar -->
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-jaxb</artifactId>
<version>${axiom.version}</version>
</dependency> <!-- axis2 axiom-adb-1.7.9.jar -->
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-adb</artifactId>
<version>${axis2.version}</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency> <!-- axis2-clustering-1.7.9.jar -->
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-clustering</artifactId>
<version>${axis2.version}</version>
</dependency> <!-- axis2-codegen-1.7.9.jar -->
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-codegen</artifactId>
<version>${axis2.version}</version>
</dependency> <!-- axis2-corba-1.7.9.jar -->
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-corba</artifactId>
<version>${axis2.version}</version>
</dependency> <!-- axis2-fastinfoset-1.7.9.jar -->
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-fastinfoset</artifactId>
<version>${axis2.version}</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency> <!-- axis2-jaxbri-1.7.9.jar -->
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-jaxbri</artifactId>
<version>${axis2.version}</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency> <!-- axis2-jaxws-1.7.9.jar -->
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-jaxws</artifactId>
<version>${axis2.version}</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency> <!-- axis2-jibx-1.7.9.jar -->
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-jibx</artifactId>
<version>${axis2.version}</version>
<exclusions>
<exclusion>
<groupId>org.jibx</groupId>
<artifactId>jibx-bind</artifactId>
</exclusion>
<exclusion>
<groupId>com.google.code.findbugs</groupId>
<artifactId>bcel-findbugs</artifactId>
</exclusion>
</exclusions>
</dependency> <!-- axis2-json-1.7.9.jar -->
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-json</artifactId>
<version>${axis2.version}</version>
</dependency> <!-- axis2-kernel-1.7.9.jar -->
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-kernel</artifactId>
<version>${axis2.version}</version>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency> <!-- axis2-metadata-1.7.9.jar -->
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-metadata</artifactId>
<version>${axis2.version}</version>
</dependency> <!-- axis2-mtompolicy-1.7.9.jar -->
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-mtompolicy</artifactId>
<version>${axis2.version}</version>
</dependency> <!-- axis2-saaj-1.7.9.jar -->
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-saaj</artifactId>
<version>${axis2.version}</version>
</dependency> <!-- axis2-soapmonitor-servlet-1.7.9.jar -->
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-soapmonitor-servlet</artifactId>
<version>${axis2.version}</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency> <!-- axis2-spring-1.7.9.jar -->
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-spring</artifactId>
<version>${axis2.version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</exclusion>
</exclusions>
</dependency> <!-- axis2-transport-base-1.7.9.jar -->
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-base</artifactId>
<version>${axis2.version}</version>
</dependency> <!-- axis2-transport-http-1.7.9.jar -->
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-http</artifactId>
<version>${axis2.version}</version>
</dependency> <!-- axis2-transport-jms-1.7.9.jar -->
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-jms</artifactId>
<version>${axis2.version}</version>
<exclusions>
<exclusion>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jms_1.1_spec</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jta_1.0.1B_spec</artifactId>
</exclusion>
</exclusions>
</dependency> <!-- axis2-transport-local-1.7.9.jar -->
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-local</artifactId>
<version>${axis2.version}</version>
</dependency> <!-- axis2-transport-mail-1.7.9.jar -->
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-mail</artifactId>
<version>${axis2.version}</version>
</dependency> <!-- axis2-transport-tcp-1.7.9.jar -->
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-tcp</artifactId>
<version>${axis2.version}</version>
</dependency> <!-- axis2-transport-udp-1.7.9.jar -->
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-udp</artifactId>
<version>${axis2.version}</version>
</dependency> <!-- axis2-transport-xmpp-1.7.9.jar -->
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-xmpp</artifactId>
<version>${axis2.version}</version>
<exclusions>
<exclusion>
<groupId>jivesoftware</groupId>
<artifactId>smack</artifactId>
</exclusion>
<exclusion>
<groupId>jivesoftware</groupId>
<artifactId>smackx</artifactId>
</exclusion>
<exclusion>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
</exclusion>
</exclusions>
</dependency> <!-- axis2-xmlbeans-1.7.9.jar -->
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-xmlbeans</artifactId>
<version>${axis2.version}</version>
</dependency> <!-- Common Codec commons-codec-1.2.jar https://mvnrepository.com/artifact/commons-codec/commons-codec -->
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</dependency> <!-- commons-fileupload-1.3.3.jar https://mvnrepository.com/artifact/commons-fileupload/commons-fileupload -->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>${commons.fileupload.version}</version>
</dependency> <!-- commons-httpclient-3.1.jar https://mvnrepository.com/artifact/commons-httpclient/commons-httpclient -->
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>${commons.httpclient.version}</version>
</dependency> <!-- commons-io-2.1.jar https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons.io.version}</version>
</dependency> <!-- commons-logging-1.1.1.jar https://mvnrepository.com/artifact/commons-logging/commons-logging -->
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>${commons.logging.version}</version>
</dependency> <!-- geronimo-annotation_1.0_spec-1.1.jar https://mvnrepository.com/artifact/org.apache.geronimo.specs/geronimo-annotation_1.0_spec -->
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-annotation_1.0_spec</artifactId>
<version>${geronimo.annotation.1.0.spec.version}</version>
</dependency> <!-- geronimo-jaxws_2.2_spec-1.0.jar https://mvnrepository.com/artifact/org.apache.geronimo.specs/geronimo-jaxws_2.2_spec -->
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jaxws_2.2_spec</artifactId>
<version>${geronimo.jaxws.2.2.spec.version}</version>
</dependency> <!-- geronimo-jta_1.1_spec-1.1.jar https://mvnrepository.com/artifact/org.apache.geronimo.specs/geronimo-jta_1.1_spec -->
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jta_1.1_spec</artifactId>
<version>${geronimo.jta.1.1.spec.version}</version>
</dependency> <!-- geronimo-saaj_1.3_spec-1.0.1.jar https://mvnrepository.com/artifact/org.apache.geronimo.specs/geronimo-saaj_1.3_spec -->
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-saaj_1.3_spec</artifactId>
<version>${org.apache.geronimo.specs.version}</version>
</dependency> <!-- geronimo-stax-api_1.0_spec-1.0.1.jar https://mvnrepository.com/artifact/org.apache.geronimo.specs/geronimo-stax-api_1.0_spec -->
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-stax-api_1.0_spec</artifactId>
<version>${org.apache.geronimo.specs.version}</version>
</dependency> <!-- geronimo-ws-metadata_2.0_spec-1.1.2.jar https://mvnrepository.com/artifact/org.apache.geronimo.specs/geronimo-ws-metadata_2.0_spec -->
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-ws-metadata_2.0_spec</artifactId>
<version>${geronimo.ws.metadata.2.0.spec.version}</version>
</dependency> <!-- gson-2.1.jar https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency> <!-- httpclient-4.5.3.jar https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency> <!-- httpcore-4.4.6.jar https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
</dependency> <!-- jaxb-api-2.2.6.jar https://mvnrepository.com/artifact/javax.xml.bind/jaxb-api -->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</dependency> <!-- jaxb-impl-2.2.6.jar https://mvnrepository.com/artifact/com.sun.xml.bind/jaxb-impl -->
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>${com.sun.xml.bind.version}</version>
</dependency>
<!-- jaxb-xjc-2.2.6.jar https://mvnrepository.com/artifact/com.sun.xml.bind/jaxb-xjc -->
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-xjc</artifactId>
<version>${com.sun.xml.bind.version}</version>
</dependency> <!-- jaxen-1.1.6.jar https://mvnrepository.com/artifact/jaxen/jaxen -->
<dependency>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
</dependency> <!-- jaxws-tools-2.2.6.jar https://mvnrepository.com/artifact/com.sun.xml.ws/jaxws-tools -->
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-tools</artifactId>
<version>${com.sun.xml.bind.version}</version>
<exclusions>
<exclusion>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-rt</artifactId>
</exclusion>
</exclusions>
</dependency> <!-- jettison-1.3.8.jar https://mvnrepository.com/artifact/org.codehaus.jettison/jettison -->
<dependency>
<groupId>org.codehaus.jettison</groupId>
<artifactId>jettison</artifactId>
<version>${jettison.version}</version>
<exclusions>
<exclusion>
<groupId>stax</groupId>
<artifactId>stax-api</artifactId>
</exclusion>
</exclusions>
</dependency> <!-- jibx-run-1.2.jar https://mvnrepository.com/artifact/org.jibx/jibx-run -->
<dependency>
<groupId>org.jibx</groupId>
<artifactId>jibx-run</artifactId>
<version>${jibx.run.version}</version>
<exclusions>
<exclusion>
<groupId>org.codehaus.woodstox</groupId>
<artifactId>wstx-asl</artifactId>
</exclusion>
</exclusions>
</dependency> <!-- jsr311-api-1.1.1.jar https://mvnrepository.com/artifact/javax.ws.rs/jsr311-api -->
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
<version>${jsr311.api.version}</version>
</dependency> <!-- juli-6.0.53.jar https://mvnrepository.com/artifact/org.apache.tomcat/juli -->
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>juli</artifactId>
<version>${juli.version}</version>
</dependency> <!-- log4j-1.2.15.jar https://mvnrepository.com/artifact/log4j/log4j -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
<exclusions>
<exclusion>
<groupId>com.sun.jmx</groupId>
<artifactId>jmxri</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jdmk</groupId>
<artifactId>jmxtools</artifactId>
</exclusion>
<exclusion>
<groupId>javax.jms</groupId>
<artifactId>jms</artifactId>
</exclusion>
</exclusions>
</dependency> <!-- mail-1.4.jar https://mvnrepository.com/artifact/javax.mail/mail -->
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>${mail.version}</version>
</dependency> <!-- mex-1.7.9-impl.jar private jar neethi-3.0.3.jar https://mvnrepository.com/artifact/org.apache.neethi/neethi -->
<dependency>
<groupId>org.apache.neethi</groupId>
<artifactId>neethi</artifactId>
<version>${neethi.version}</version>
</dependency> <!-- stax2-api-3.1.1.jar https://mvnrepository.com/artifact/org.codehaus.woodstox/stax2-api -->
<dependency>
<groupId>org.codehaus.woodstox</groupId>
<artifactId>stax2-api</artifactId>
<version>${stax2.api.version}</version>
<exclusions>
<exclusion>
<groupId>javax.xml.stream</groupId>
<artifactId>stax-api</artifactId>
</exclusion>
</exclusions>
</dependency> <!-- taglibs-standard-impl-1.2.5.jar https://mvnrepository.com/artifact/org.apache.taglibs/taglibs-standard-impl -->
<dependency>
<groupId>org.apache.taglibs</groupId>
<artifactId>taglibs-standard-impl</artifactId>
<version>${org.apache.taglibs.version}</version>
</dependency> <!-- taglibs-standard-spec-1.2.5.jar https://mvnrepository.com/artifact/org.apache.taglibs/taglibs-standard-impl -->
<dependency>
<groupId>org.apache.taglibs</groupId>
<artifactId>taglibs-standard-spec</artifactId>
<version>${org.apache.taglibs.version}</version>
</dependency> <!-- tribes-6.0.53.jar https://mvnrepository.com/artifact/org.apache.tomcat/tribes -->
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tribes</artifactId>
<version>${tribes.version}</version>
</dependency> <!-- woden-core-1.0M10.jar https://mvnrepository.com/artifact/org.apache.woden/woden-core -->
<dependency>
<groupId>org.apache.woden</groupId>
<artifactId>woden-core</artifactId>
<version>${woden.core.version}</version>
<exclusions>
<exclusion>
<groupId>javax.xml.stream</groupId>
<artifactId>stax-api</artifactId>
</exclusion>
</exclusions>
</dependency> <!-- woodstox-core-asl-4.2.0.jar https://mvnrepository.com/artifact/org.codehaus.woodstox/woodstox-core-asl -->
<dependency>
<groupId>org.codehaus.woodstox</groupId>
<artifactId>woodstox-core-asl</artifactId>
<version>${woodstox.core.asl.version}</version>
<exclusions>
<exclusion>
<groupId>javax.xml.stream</groupId>
<artifactId>stax-api</artifactId>
</exclusion>
</exclusions>
</dependency> <!-- wsdl4j-1.6.2.jar https://mvnrepository.com/artifact/wsdl4j/wsdl4j -->
<dependency>
<groupId>wsdl4j</groupId>
<artifactId>wsdl4j</artifactId>
</dependency> <!-- xalan-2.7.0.jar https://mvnrepository.com/artifact/xalan/xalan -->
<dependency>
<groupId>xalan</groupId>
<artifactId>xalan</artifactId>
<version>${xalan.version}</version>
<exclusions>
<exclusion>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
</exclusions>
</dependency> <!-- xmlbeans-2.6.0.jar https://mvnrepository.com/artifact/org.apache.xmlbeans/xmlbeans -->
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>${xmlbeans.version}</version>
<exclusions>
<exclusion>
<groupId>stax</groupId>
<artifactId>stax-api</artifactId>
</exclusion>
</exclusions>
</dependency> <!-- xml-resolver-1.2.jar https://mvnrepository.com/artifact/xml-resolver/xml-resolver -->
<dependency>
<groupId>xml-resolver</groupId>
<artifactId>xml-resolver</artifactId>
<version>${xml.resolver.version}</version>
<exclusions>
<exclusion>
<groupId>org.apache.ws.xmlschema</groupId>
<artifactId>xmlschema-core</artifactId>
</exclusion>
</exclusions>
</dependency> <!-- xmlschema-core-2.2.1.jar https://mvnrepository.com/artifact/org.apache.ws.xmlschema/xmlschema-core -->
<dependency>
<groupId>org.apache.ws.xmlschema</groupId>
<artifactId>xmlschema-core</artifactId>
<version>${xmlschema.core.version}</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies> <dependencyManagement>
<!-- 解决版本冲突 -->
<dependencies>
<dependency>
<groupId>antlr</groupId>
<artifactId>antlr</artifactId>
<version>2.7.7</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.2.6</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.3</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.6</version>
</dependency>
<dependency>
<groupId>wsdl4j</groupId>
<artifactId>wsdl4j</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
<version>1.1.6</version>
</dependency>
</dependencies>
</dependencyManagement> <!-- config -->
<properties>
<java.version>1.8</java.version>
<antlr2.version>2.7.7</antlr2.version>
<activation.version>1.1</activation.version>
<axis2.version>1.7.9</axis2.version>
<axiom.version>1.2.21</axiom.version>
<apache.mime4j.core.version>0.7.2</apache.mime4j.core.version>
<commons.fileupload.version>1.3.3</commons.fileupload.version>
<commons.httpclient.version>3.1</commons.httpclient.version>
<commons.io.version>2.1</commons.io.version>
<xmlschema.core.version>2.2.1</xmlschema.core.version>
<xml.resolver.version>1.2</xml.resolver.version>
<xmlbeans.version>2.6.0</xmlbeans.version>
<xalan.version>2.7.0</xalan.version>
<woodstox.core.asl.version>4.2.0</woodstox.core.asl.version>
<woden.core.version>1.0M10</woden.core.version>
<tribes.version>6.0.53</tribes.version>
<org.apache.taglibs.version>1.2.5</org.apache.taglibs.version>
<stax2.api.version>3.1.1</stax2.api.version>
<neethi.version>3.0.3</neethi.version>
<mail.version>1.4</mail.version>
<log4j.version>1.2.15</log4j.version>
<juli.version>6.0.53</juli.version>
<jsr311.api.version>1.1.1</jsr311.api.version>
<jibx.run.version>1.2</jibx.run.version>
<jettison.version>1.3.8</jettison.version>
<geronimo.ws.metadata.2.0.spec.version>1.1.2</geronimo.ws.metadata.2.0.spec.version>
<com.sun.xml.bind.version>2.2.6</com.sun.xml.bind.version>
<org.apache.geronimo.specs.version>1.0.1</org.apache.geronimo.specs.version>
<geronimo.jta.1.1.spec.version>1.1</geronimo.jta.1.1.spec.version>
<geronimo.jaxws.2.2.spec.version>1.0</geronimo.jaxws.2.2.spec.version>
<geronimo.annotation.1.0.spec.version>1.1</geronimo.annotation.1.0.spec.version>
<commons.logging.version>1.1.1</commons.logging.version>
</properties>
<!-- Build Config -->
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

可以先发布到tomcat 容器中

到这里第一步准备就完成了。

2. 了解 Axis2 Service 目录结构

Axis2的服务器端可以部署在任何Servlet引擎上,站看我们刚才创建的项目可以看到如下项目结构:

代码清单2:axis2.war的目录结构

注意:

最重要的是 axis2.xml,它控制应用程序如何处理收到的消息,确定Axis2是否需要应用modules目录中定义的任何模块。

Axis2 管理控制台的登陆账号密码也在这个配置文件里面。

services 文件夹下可以放*.aar 文件,也可以放services.xml 文件

3. 部署POJO

方法一:通过ANT 生成 WSDL 文件

安装配置ANT

接下来我们还需要安装下Ant, 因为待会要通过ANT命令构建我们的Web Service.

1. 打开Ant 官网:https://ant.apache.org/bindownload.cgi

2. 我们可以看到当前可能是这样的,我们下载最新版本。

Tips: 由于是windows 系统演示,因此我摸下载的是图中所示的zip,如果是linux 系统可以下载 tar.xz 格式

3. 配置环境变量

新建一个系统环境变量

ANT_HOME
C:\Apps\apache-ant\apache-ant-1.10.5

如图所示:

添加到Path 中

%ANT_HOME%\bin\

如图所示:

验证:

ant -version

安装成功会像这样


ANT编译生成WSDL

要使用POJO(Plain Old Java Objects)部署服务,请执行以下步骤。

注意:这里我们使用官方给的样例源码中来演示

解压下载的二进制文件,比如我的存放位置如下:

E:\open-source\axis2\axis2-1.7.9-bin\axis2-1.7.9\samples

我们打开那个quickstart 文件夹,命令行进入这个文件夹:

前面我们已经安装配置好了ant 构建工具,因此这里只需要在命令行下通过键入以下内容就可以从quickstart目录生成WSDL:

ant generate.wsdl

执行成功会显示如下:

我们可以看到多了一个build 文件夹

点进去可以看到有一个WSDL 文件(WSDL,  Web Services Description Language的简写 )

这个文件是 StockQuoteSevice.java Web Service 的描述文件

打开这个文件可以看下

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns="http://quickstart.samples/xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:tns="http://quickstart.samples/" targetNamespace="http://quickstart.samples/">
<wsdl:types>
<xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://quickstart.samples/xsd">
<xs:element name="update">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="" name="symbol" nillable="true" type="xs:string"/>
<xs:element name="price" type="xs:double"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="getPrice">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="" name="symbol" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="getPriceResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="return" type="xs:double"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</wsdl:types>
<wsdl:message name="updateRequest">
<wsdl:part name="parameters" element="ns:update"/>
</wsdl:message>
<wsdl:message name="getPriceRequest">
<wsdl:part name="parameters" element="ns:getPrice"/>
</wsdl:message>
<wsdl:message name="getPriceResponse">
<wsdl:part name="parameters" element="ns:getPriceResponse"/>
</wsdl:message>
<wsdl:portType name="StockQuoteServicePortType">
<wsdl:operation name="update">
<wsdl:input message="tns:updateRequest" wsaw:Action="urn:update"/>
</wsdl:operation>
<wsdl:operation name="getPrice">
<wsdl:input message="tns:getPriceRequest" wsaw:Action="urn:getPrice"/>
<wsdl:output message="tns:getPriceResponse" wsaw:Action="urn:getPriceResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="StockQuoteServiceSoap11Binding" type="tns:StockQuoteServicePortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="update">
<soap:operation soapAction="urn:update" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
</wsdl:operation>
<wsdl:operation name="getPrice">
<soap:operation soapAction="urn:getPrice" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="StockQuoteServiceSoap12Binding" type="tns:StockQuoteServicePortType">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="update">
<soap12:operation soapAction="urn:update" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
</wsdl:operation>
<wsdl:operation name="getPrice">
<soap12:operation soapAction="urn:getPrice" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="StockQuoteServiceHttpBinding" type="tns:StockQuoteServicePortType">
<http:binding verb="POST"/>
<wsdl:operation name="update">
<http:operation location="update"/>
<wsdl:input>
<mime:content type="application/xml" part="parameters"/>
</wsdl:input>
</wsdl:operation>
<wsdl:operation name="getPrice">
<http:operation location="getPrice"/>
<wsdl:input>
<mime:content type="application/xml" part="parameters"/>
</wsdl:input>
<wsdl:output>
<mime:content type="application/xml" part="parameters"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="StockQuoteService">
<wsdl:port name="StockQuoteServiceHttpSoap11Endpoint" binding="tns:StockQuoteServiceSoap11Binding">
<soap:address location="http://localhost:8080/axis2/services/StockQuoteService"/>
</wsdl:port>
<wsdl:port name="StockQuoteServiceHttpSoap12Endpoint" binding="tns:StockQuoteServiceSoap12Binding">
<soap12:address location="http://localhost:8080/axis2/services/StockQuoteService"/>
</wsdl:port>
<wsdl:port name="StockQuoteServiceHttpEndpoint" binding="tns:StockQuoteServiceHttpBinding">
<http:address location="http://localhost:8080/axis2/services/StockQuoteService"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

Tips: 这个WSDL 文件可以用Ant 命令根据java代码生成,也可以通过services.xml 配置经过浏览器访问URL 生成。

方法二:通过URL访问生成WSDL 文件

接下来我们就尝试通过URL访问生成WSDL 文件

打开我们自己创建的工程,我们需要在services 目录下创建一个文件夹 StockQuoteService

注意:这个名字必须和services.xml 中name 节点的值保持一致。

其次还需要创建一个META-INF 文件夹,将我们的services.xml 放进去(这个文件可以在样例源码中找到)

文件路径:C:\Apps\axis2\axis2-1.7.9\samples\quickstart\resources\META-INF\services.xml

内容如下:

<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
--> <service name="StockQuoteService" scope="application" targetNamespace="http://quickstart.samples/">
<description>
Stock Quote Service
</description>
<messageReceivers>
<messageReceiver mep="http://www.w3.org/ns/wsdl/in-only"
class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"/>
<messageReceiver mep="http://www.w3.org/ns/wsdl/in-out"
class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
</messageReceivers>
<schema schemaNamespace="http://quickstart.samples/xsd"/>
<parameter name="ServiceClass">samples.quickstart.service.pojo.StockQuoteService</parameter>
</service>

其次创建的web service Java源码部分结构如下

这个StockQuoteService.java 文件可以在样例源码中找到

文件路径:E:\open-source\axis2\axis2-1.7.9-bin\axis2-1.7.9\samples\quickstart\src\samples\quickstart\service\pojo\StockQuoteService.java

文件内容如下:

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package samples.quickstart.service.pojo; import java.util.HashMap; public class StockQuoteService { private HashMap<String,Double> map = new HashMap<String,Double>(); public double getPrice(String symbol) {
Double price = (Double) map.get(symbol);
if(price != null){
return price.doubleValue();
}
return 42.00;
} public void update(String symbol, double price) {
map.put(symbol, new Double(price));
}
}

Tips: 为了去掉警告,我做了简单修改,当然不修改也没问题

部署发布到tomcat 或者其他web 容器成功后可以看到

然后通过查看以下服务列表来检查以确保服务已正确部署:

http://localhost:8080/axis2-webapp-pojo-sample/services/listServices

我们可以看到除了默认的Version Services 之外,我们自定义的Web Service 也部署上去了。

您还可以在以下位置查看WSDL:

http://localhost:8080/axis2-webapp-pojo-sample/services/StockQuoteService?wsdl

访问成功如下所示:

the schema 在

http://localhost:8080/axis2-webapp-pojo-sample/services/StockQuoteService?xsd

URL正常工作后,快速测试服务。尝试将浏览器指向以下URL:

http://localhost:8080/axis2-webapp-pojo-sample/services/StockQuoteService/getPrice?symbol=IBM

我们将收到以下响应:

如果我们调用更新方法,

http://localhost:8080/axis2-webapp-pojo-sample/services/StockQuoteService/update?symbol=IBM&price=100.00

Tips: 但是由于更新方法是没有返回值的,因此页面可能看不到什么变化

然后执行第一个getPrice URL,您将看到价格已更新。

http://localhost:8080/axis2-webapp-pojo-sample/services/StockQuoteService/getPrice?symbol=IBM

效果如下所示:

本篇完~

2.1 Apache Axis2 快速学习手册之 POJO 构建Web Service的更多相关文章

  1. 2.2 Apache Axis2 快速学习手册之 AXIOM 构建 Web Service

    和上一篇的POJO 部署相比主要是services.xml 中配置的消息接受处理器类不一样和Java 类中写法不一样. 使用AXIOM构建服务 样例源码路径: C:\Apps\axis2\axis2- ...

  2. 2.3 Apache Axis2 快速学习手册之 ADB 构建Web Service

    使用ADB生成服务(根据ADB 命令将wsdl 文件还原成Java代码) 要使用Axis2数据绑定框架(ADB)生成和部署服务,请执行以下步骤. 通过在Axis2_HOME / samples / q ...

  3. 2.5 Apache Axis2 快速学习手册之JiBx 构建Web Service

    5. 使用JiBX生成服务(通过JIBX 命令将wsdl 生成 services ) 要使用JiBX数据绑定生成和部署服务,请执行以下步骤. 通过在Axis2_HOME / samples / qui ...

  4. 2.4 Apache Axis2 快速学习手册之XMLBeans 构建Web Service

    4. 使用XMLBeans生成服务(通过xml bean 命令将wsdl 文件生成java 代码) 要使用XMLBeans生成服务,请执行以下步骤. 通过在Axis2_HOME / samples / ...

  5. 2. Apache Axis2 快速学习手册之概览

    这篇博文和大家一起学习下Apache Axis2 官方文档的快速指南篇 英文原文:http://axis.apache.org/axis2/java/core/docs/quickstartguide ...

  6. Eclipse利用Axis2插件构建Web Service并测试

    在学习Web Service的时候,从网上找到前辈的博客http://www.cnblogs.com/hexinlin/p/3358558.html,并依此文的方法按部就班:编写欲发布的java类He ...

  7. Spring学习(七)——开发Web Service的几种方式

    本文作者在学习使用Java开发Web Service(不包括Restful)时,由于不知道Java有这么多框架支持开发Web Service一度陷入迷惘,不知道这些框架各有 什么不同,各有什么优缺点. ...

  8. 【webpack插件使用】在开发中快速掌握并使用Webpack构建web应用程序

    1.webpack-dev-server插件的基本使用 入门程序 const path = require('path'); // 导出一个Webpack的配置对象(通过node中的模块操作,向外暴露 ...

  9. 1. Apache Axis2 下载安装入门

    Apache Axis2 /Java 学习手册   by 星云 0x01 什么是Apache Axis2/Java? Apache Axis2™ 是一个Web Service / SOAP / WSD ...

随机推荐

  1. cocos2d-js 在线更新代码脚本 动态更新脚本程序 热更新 绕过平台审核 不需重新上架

    2014年8月15日补充 cocos2d-js 3.0 rc0 的AssetsManager有缺陷,有一些注意点:(可以阅读源代码发现) 1.旧manifest中有,但新manifest中没有的文件( ...

  2. iOS UI01_Label

    @implementation AppDelegate -(void)dealloc { [_window release]; [superdealloc]; } - (BOOL)applicatio ...

  3. 虚拟机在NAT模式下主机与宿主机的ip配置

    现有如下环境: 宿主机:win7 (IP为100.101.201.20) 虚拟机: SUSE LinuxEterprise 11 64bit (IP为100.101.201.23) 连接模式如下图: ...

  4. windows 10 更新失败及应用商店重装问题解决记录

    简单的记录一下这次遇到的问题及解决办法. 使用的windows 10 企业版一直不能更新成功,各种办法都试过了,都是失败然后回退. 这次直接下载了1709的映像进行升级安装的,因为我的是双系统,升级安 ...

  5. RHEL7 光盘修复

    光盘修复#rm -rf /boot/*#dd if=/dev/zero of=/dev/sda bs=446 count=1#systemctl rebootTroubleshooting(排错模式) ...

  6. Linux的telent服务

    目前,在Win/Linux下telnet都很少用了,只是因为数据在传输的过程,未加密!不过在Linux下还是多用于端口探测,今天就来回顾曾经的telnet 1.介绍 Linux被广泛运用到各种服务器及 ...

  7. Textview文字监控(输入到某个字符后,进行操作)

      以手机号充值为例,当用户输入最后一位数时候,进行汇率的变换.   1.首先给用户添加一个textchangedlistener   2.然后再写一个文字变化的监视器   mobile_et.add ...

  8. MySQL的INSERT ··· ON DUPLICATE KEY UPDATE使用的几种情况

    在MySQL数据库中,如果在insert语句后面带上ON DUPLICATE KEY UPDATE 子句,而要插入的行与表中现有记录的惟一索引或主键中产生重复值,那么就会发生旧行的更新:如果插入的行数 ...

  9. ios中布局(推荐一)

    - (void)viewDidLoad { [super viewDidLoad]; NSArray *data=@[@"标题一",@"标题二",@" ...

  10. HDU 1850 Being a Good Boy in Spring Festival (Nim博弈)

    Being a Good Boy in Spring Festival Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32 ...