axis2-1.7.6作为例子说明
加入axis2相关的依赖包pom.xml
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-kernel</artifactId>
<version>${version.axis2}</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-adb</artifactId>
<version>${version.axis2}</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-http</artifactId>
<version>${version.axis2}</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-local</artifactId>
<version>${version.axis2}</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-java2wsdl</artifactId>
<version>${version.axis2}</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-codegen</artifactId>
<version>${version.axis2}</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-spring</artifactId>
<version>${version.axis2}</version>
</dependency>
web.xml中加入axis2的配置,如果不用支持https,可以不用配置axis2.xml
<servlet>
<servlet-name>AxisServlet</servlet-name>
<servlet-class>org.apache.axis2.transport.http.AxisServlet</servlet-class>
<init-param>
<param-name>axis2.xml.path</param-name>
<param-value>./xxx/axis2.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>/services/*</url-pattern>(该目录下放.aar文件)
</servlet-mapping>
application-context.xml中启动webservice要访问的类
<bean id="assistServiceImpl" class="xx.xx.ws.impl.AssistServiceImpl"></bean>
<bean></bean>
<context:annotation-config />
去apache官网上下载axis2的 axis2-1.7.6-bin.zip包
http://axis.apache.org/axis2/java/core/download.html
把axis2.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.
-->
<axisconfig name="AxisJava2.0">
<!-- ================================================= -->
<!-- Parameters -->
<!-- ================================================= -->
<parameter name="hotdeployment">true</parameter>
<parameter name="hotupdate">false</parameter>
<parameter name="enableMTOM">false</parameter>
<parameter name="enableSwA">false</parameter>
<!--Uncomment if you want to enable file caching for attachments -->
<!--parameter name="cacheAttachments">true</parameter>
<parameter name="attachmentDIR"></parameter>
<parameter name="sizeThreshold">4000</parameter-->
<parameter name="EnableChildFirstClassLoading">false</parameter>
<!--
The exposeServiceMetadata parameter decides whether the metadata (WSDL, schema, policy) of
the services deployed on Axis2 should be visible when ?wsdl, ?wsdl2, ?xsd, ?policy requests
are received.
This parameter can be defined in the axi2.xml file, in which case this will be applicable
globally, or in the services.xml files, in which case, it will be applicable to the
Service groups and/or services, depending on the level at which the parameter is declared.
This value of this parameter defaults to true.
-->
<parameter name="exposeServiceMetadata">true</parameter>
<!--Uncomment if you want to plugin your own attachments lifecycle implementation -->
<!--<attachmentsLifecycleManager class="org.apache.axiom.attachments.lifecycle.impl.LifecycleManagerImpl"/>-->
<!--Uncomment if you want to enable the reduction of the in-memory cache of WSDL definitions -->
<!--In some server environments, the available memory heap is limited and can fill up under load -->
<!--Since in-memory copies of WSDL definitions can be large, some steps can be taken-->
<!--to reduce the memory needed for the cached WSDL definitions. -->
<!--parameter name="reduceWSDLMemoryCache">true</parameter-->
<!--This will give out the timout of the configuration contexts, in milliseconds-->
<parameter name="ConfigContextTimeoutInterval">30000</parameter>
<!--During a fault, stack trace can be sent with the fault message. The following flag will control -->
<!--that behavior.-->
<parameter name="sendStacktraceDetailsWithFaults">false</parameter>
<!--If there aren't any information available to find out the fault reason, we set the message of the exception-->
<!--as the faultreason/Reason. But when a fault is thrown from a service or some where, it will be -->
<!--wrapped by different levels. Due to this the initial exception message can be lost. If this flag-->
<!--is set, then Axis2 tries to get the first exception and set its message as the faultreason/Reason.-->
<parameter name="DrillDownToRootCauseForFaultReason">false</parameter>
<parameter name="userName">admin</parameter>
<parameter name="password">axis2</parameter>
<!--To override repository/services you need to uncomment following parameter and value SHOULD be absolute file path.-->
<!--ServicesDirectory only works on the following cases-->
<!---File based configurator and in that case the value should be a file URL (http:// not allowed)-->
<!---When creating URL Based configurator with URL file:// -->
<!--- War based configurator with expanded case , -->