webservice+axis2+spring+http/https

本文介绍了如何使用Axis2 1.7.6版本结合Spring来构建Webservice,并且详细阐述了配置过程,包括在pom.xml中添加依赖,web.xml的设置,axis2.xml(可选)的配置,以及服务的发布步骤。内容涵盖axis2.xml的修改,services.xml的定制,aar文件的打包和部署,最终形成符合预期的目录结构。
摘要由CSDN通过智能技术生成

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 , -->

    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值