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. join联表查询方法

    $model = Shipping::join('shipping_area', 'shipping_area.shipping_id', '=', 'shipping.shipping_id') - ...

  2. Flash和js交互的效率分析

    Flash和js交互的效率分析   AS代码: var time:int = getTimer(); for (var i:int = 0; i < 50000; i++) { External ...

  3. Java千百问_05面向对象(005)_接口和抽象类有什么差别

    点击进入_很多其它_Java千百问 1.接口和抽象类有什么差别 在Java语言中.抽象类abstract class和接口interface是抽象定义的两种机制. 正是因为这两种机制的存在,才赋予了J ...

  4. excel如何快速更改表格边框的颜色

    1.当完成基本的表格设置之后,对颜色不甚满意,怎么办 2.重新给表格选择一种颜色,这里会出现一个“笔”形状的鼠标箭头,不用理睬她 3.再次给表格统一加边框即可(开始--边框--所有框线)

  5. [转载]Windows x64下配置ffmpeg的方法

    ffmpeg简介 FFmpeg 是一款跨平台的,对视频.音频进行录制.转换.播放的命令行形式软件,它使用的是 libavcodec 编解码器.FFmpeg 官方网站是 http://ffmpeg.or ...

  6. 转:OGRE 渲染通路(Pass)

    一个渲染通路就是几何问题里的一次渲染:一个带有一整套渲染属性的渲染API的一次调用.一个技术可以包含有1到16个渲染通路,当然,渲染通路用得越多,技术在渲染的时候开销越大. 为了清楚识别使用的到底是哪 ...

  7. HttpServer发送数据到kafka

    文件夹 1.需求 2.框架结构图和步鄹图 3.代码结构 4.代码展现 ------------------------ 1.需求 1.1.解析路径,将路径的最后一个字符串作为Appkey: 1.2.数 ...

  8. swift类型转换之Could not cast value of type xxx to xxx错误的一种特殊情况记录

    之前swift项目打包成Framework静态库,提供给OC项目套入使用时,有时会抱这样一个错误: 这个错误发生的概率比较随机,有时会,有时不会,而且这句话在swift中的使用,是做model类型强制 ...

  9. java计算时间差, 日期差小结

    转自:https://blog.csdn.net/sy793314598/article/details/79544796 1.java 7中的日历类Calendar Calendar类使用其静态的g ...

  10. maven-compiler-plugin升级到3.1出现问题(转)

    转自:http://my.oschina.net/zhuka/blog/124503 No compiler is provided in this environment. Perhaps you ...