一.開發環境:Tomcat(下載地址:http://tomcat.apache.org/download-60.cgi)、MyEclipse(下載地址:http://www.myeclipseide.cn/),Axis2(下載地址:http://axis.apache.org/axis2/java/core/download.cgi)。java
二.MyEclipse插件:axis2-eclipse-codegen-wizard.zip(下載地址:http://files.cnblogs.com/sky-of-chuanqingchen/axis2-eclipse-codegen-wizard.zip),axis2-eclipse-service-archiver-wizard.zip(下載地址:http://files.cnblogs.com/sky-of-chuanqingchen/axis2-eclipse-service-archiver-wizard.zip)。web
1.安裝MyEclipse插件:將上述兩個插件解壓,再將解壓後的文件複製到MyEclipse安裝路徑下的dropins目錄,最後重啓MyEclipse。(注:如在使用axis2 code generator建立wsdl文件的時候報錯,報錯信息以下圖,可按照第三步的流程操做)。express
2.檢查是否成功安裝MyEclipse插件,打開MyEclipse的File->New->Other,插件安裝成功後以下圖。apache
3.對axis2-eclipse-codegen-wizard.zip解壓出來的文件作以下修改。api
a.首先,修改plugin.xml文件,更改成以下代碼。tomcat
1 <?xml version="1.0" encoding="UTF-8"?> 2 <?eclipse version="3.0"?> 3 4 <!-- 5 ~ Licensed to the Apache Software Foundation (ASF) under one 6 ~ or more contributor license agreements. See the NOTICE file 7 ~ distributed with this work for additional information 8 ~ regarding copyright ownership. The ASF licenses this file 9 ~ to you under the Apache License, Version 2.0 (the 10 ~ "License"); you may not use this file except in compliance 11 ~ with the License. You may obtain a copy of the License at 12 ~ 13 ~ http://www.apache.org/licenses/LICENSE-2.0 14 ~ 15 ~ Unless required by applicable law or agreed to in writing, 16 ~ software distributed under the License is distributed on an 17 ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 18 ~ KIND, either express or implied. See the License for the 19 ~ specific language governing permissions and limitations 20 ~ under the License. 21 --> 22 23 <plugin 24 id="Axis2_Codegen_Wizard" 25 name="Axis2 Codegen Wizard Plug-in" 26 version="1.3.0" 27 provider-name="Apache Software Foundation" 28 class="org.apache.axis2.tool.codegen.eclipse.plugin.CodegenWizardPlugin"> 29 30 <runtime> 31 <library name="Axis2CodegenWizard.jar"> 32 <export name="*"/> 33 </library> 34 <library name="lib/geronimo-activation_1.1_spec-1.0.1.jar"> 35 <export name="*"/> 36 </library> 37 <library name="lib/annogen-0.1.0.jar"> 38 <export name="*"/> 39 </library> 40 <library name="lib/ant-1.7.0.jar"> 41 <export name="*"/> 42 </library> 43 <library name="lib/axiom-api-1.2.7.jar"> 44 <export name="*"/> 45 </library> 46 <library name="lib/axiom-dom-1.2.7.jar"> 47 <export name="*"/> 48 </library> 49 <library name="lib/axiom-impl-1.2.7.jar"> 50 <export name="*"/> 51 </library> 52 <library name="lib/commons-logging-1.1.1.jar"> 53 <export name="*"/> 54 </library> 55 <library name="lib/axis2-1.4.1.jar"> 56 <export name="*"/> 57 </library> 58 <library name="lib/log4j-1.2.15.jar"> 59 <export name="*"/> 60 </library> 61 <library name="lib/neethi-2.0.4.jar"> 62 <export name="*"/> 63 </library> 64 <library name="lib/stax-api-1.0.1.jar"> 65 <export name="*"/> 66 </library> 67 <library name="lib/wsdl4j-1.6.2.jar"> 68 <export name="*"/> 69 </library> 70 <library name="lib/wstx-asl-3.2.4.jar"> 71 <export name="*"/> 72 </library> 73 <library name="lib/xmlbeans-2.3.0.jar"> 74 <export name="*"/> 75 </library> 76 <library name="lib/XmlSchema-1.4.2.jar"> 77 <export name="*"/> 78 </library> 79 <library name="lib/woden-1.0M8.jar"> 80 <export name="*"/> 81 </library> 82 <library name="lib/commons-httpclient-3.1.jar"> 83 <export name="*"/> 84 </library> 85 <library name="lib/commons-codec-1.3.jar"> 86 <export name="*"/> 87 </library> 88 <library name="lib/jibx-bind-1.1.5.jar"> 89 <export name="*"/> 90 </library> 91 <library name="lib/jibx-run-1.1.5.jar"> 92 <export name="*"/> 93 </library> 94 <library name="lib/geronimo-stax-api_1.0_spec-1.0.1.jar"> 95 <export name="*"/> 96 </library> 97 <library name="lib/backport-util-concurrent-3.1.jar"> 98 <export name="*"/> 99 </library> 100 </runtime> 101 102 <requires> 103 <import plugin="org.eclipse.ui"/> 104 <import plugin="org.eclipse.ui.ide"/> 105 <import plugin="org.eclipse.core.runtime"/> 106 <import plugin="org.eclipse.core.resources"/> 107 <import plugin="org.apache.ant"/> 108 </requires> 109 110 <extension 111 point="org.eclipse.ui.newWizards"> 112 <category 113 name="Axis2 Wizards" 114 id="Axis2_Wizards"> 115 </category> 116 <wizard 117 name="Axis2 Code Generator" 118 icon="icons/icon.gif" 119 category="Axis2_Wizards" 120 class="org.apache.axis2.tool.codegen.eclipse.CodeGenWizard" 121 id="org.apache.axis2.tool.codegen.eclipse.CodeGenWizard"> 122 </wizard> 123 </extension> 124 <extension point="org.eclipse.help.toc"> 125 <toc file="help_toc.xml" primary="true" /> 126 </extension> 127 128 </plugin>
plugin.xml對比原始文件主要增長以下內容:服務器
<library name="lib/geronimo-stax-api_1.0_spec-1.0.1.jar">
<export name="*"/>
</library>
<library name="lib/backport-util-concurrent-3.1.jar">
<export name="*"/>
</library>app
b.其次,增長以下兩個jar包(geronimo-stax-api_1.0_spec-1.0.1.jar、backport-util-concurrent-3.1.jar)到axis2-eclipse-codegen-wizard.zip所解壓出來文件的lib目錄下,(附jar包下載地址:http://files.cnblogs.com/sky-of-chuanqingchen/for_axis_code_generator.rar)。less
三.開發一個簡單的web service程序。dom
1.使用MyEclipse開發工具新建web service 項目,File->New->Web Service Project,以下圖。
2.將 axis2-1.6.2-war.zip解壓出來,再將裏面axis2.war解壓出來,而後把解壓出來的文件複製到axis2所在項目的WebRoot目錄下,目錄結構以下所示。
3.編寫test.SimpleTest類,代碼以下。
1 package test; 2 3 public class SimpleTest { 4 public String simpleMethod(String name) { 5 return name + "Say: this is a Simple test method ^-^"; 6 } 7 }
4.使用axis2 service archiver建立配置文件。
(注:output file location選擇axis2所在項目目錄下的\WebRoot\WEB-INF\services目錄)
5.重啓Tomcat服務器,打開url:http://localhost:8080/axis2/services/listServices,檢查是否成功。
About MORE Axis2的相關資料,待續^-^