axis服务端开发遇到的问题

axis 配置的webservice一直启动报错。原因是由于axis的版本问题。先从配置说起:

axis2服务端开发很容易对于maven项目 配置好pom文件

	   <dependency>
                <groupId>org.apache.axis2</groupId>
                <artifactId>axis2</artifactId>
                <version>1.7.6</version>
            </dependency>
            <dependency>
                <groupId>org.apache.axis2</groupId>
                <artifactId>axis2-spring</artifactId>
                <version>1.7.6</version>
            </dependency>
            <dependency>
                <groupId>org.apache.axis2</groupId>
                <artifactId>axis2-transport-http</artifactId>
                <version>1.7.6</version>
            </dependency>
            <dependency>
                <groupId>org.apache.axis2</groupId>
                <artifactId>axis2-transport-local</artifactId>
                <version>1.7.6</version>
            </dependency>
            <dependency>
                <groupId>org.apache.axis2</groupId>
                <artifactId>axis2-xmlbeans</artifactId>
                <version>1.7.6</version>
            </dependency>


注意这里用的是1.7.6版本。这个版本支持java8的特性

用1.6.x的版本这里不支持java8的特性。我当时就是用的这个版本所以启动一直报错。网上说pojo不能实例化。

配置services.xml。在工程WEB-INF\services\xxx\META-INF\services.xml   以及 ServiceData.xml 其中xxx目录必须有。

services.xml文件

<serviceGroup>
    <service name="wmsWebservice" >
        <description>
            Test Service Example
        </description>
        <parameter name="ServiceObjectSupplier"><!-- 固定 -->
            org.apache.axis2.extensions.spring.receivers.SpringServletContextObjectSupplier
        </parameter>
        <parameter name="SpringBeanName">wmsBusinessServiceImpl</parameter><!-- bean名字 -->
        <parameter name="ServiceClass">
            com.unlcn.ils.wms.api.webservice.server.WmsBusinessServiceImpl
        </parameter>
        <messageReceivers>
            <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only" class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"/>
            <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out" class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
        </messageReceivers>
    </service>
</serviceGroup>

servicesData.xml

<?xml version="1.0" encoding="UTF-8"?>
<ServiceData>
</ServiceData>


在web.xml

 <servlet>
    <servlet-name>AxisServlet</servlet-name>
    <servlet-class>org.apache.axis2.transport.http.AxisServlet</servlet-class>
    <!--<init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>classpath:spring/applicationContext-mvc.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>
  </servlet-mapping>

applicationContext-xxxxx.xml  颜色部分为需要的axis配置

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
             xmlns:beans="http://www.springframework.org/schema/beans"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
    http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-4.0.xsd">

    <!-- There are four annotations which support expression attributes to allow pre and post-invocation authorization checks and also to support
        filtering of submitted collection arguments or return values. They are @PreAuthorize, @PreFilter, @PostAuthorize and @PostFilter. Their use is
        enabled through the global-method-security namespace element: -->
    <global-method-security pre-post-annotations="enabled"/>

    <http entry-point-ref="jwtAuthenticationEntryPoint" create-session="stateless">
        <csrf disabled="true"/>
        <intercept-url pattern="/resources/**" access="permitAll"/>
        <intercept-url pattern="/images/**" access="permitAll"/>
        <intercept-url pattern="/css/**" access="permitAll"/>
        <intercept-url pattern="/js/**" access="permitAll"/>
        <intercept-url pattern="/test*" access="permitAll"/>
        <intercept-url pattern="/login/**" access="permitAll"/>
        <intercept-url pattern="/signin/**" access="permitAll"/>
        <intercept-url pattern="/auth/**" access="permitAll"/>
        <intercept-url pattern="/pay/**" access="isAuthenticated()"/>
        <intercept-url pattern="/pay/finish" access="permitAll"/>
        <intercept-url pattern="/pay/finish/**" access="permitAll"/>
        <!-- <intercept-url pattern="/qiniu/**" access="isAuthenticated()" /> -->
        <intercept-url pattern="/user/**" access="permitAll"/>
        <intercept-url pattern="/pingpp/**" access="isAuthenticated()"/>
        <intercept-url pattern="/bank/**" access="isAuthenticated()"/>
        <intercept-url pattern="/cash/**" access="isAuthenticated()"/>
        <intercept-url pattern="/accntDetail/**" access="isAuthenticated()"/>
        <intercept-url pattern="/accntLedger/**" access="isAuthenticated()"/>
        <intercept-url pattern="/area/**" access="isAuthenticated()"/>
        <intercept-url pattern="/waybill/**" access="permitAll"/>
        <intercept-url pattern="/addr/**" access="isAuthenticated()"/>
        <intercept-url pattern="/tmsimport/**" access="isAuthenticated()"/>
        <intercept-url pattern="/about/**" access="isAuthenticated()"/>
        <intercept-url pattern="/tmsadmin/**" access="isAuthenticated()"/>
        <!-- <intercept-url pattern="/**" access="isAuthenticated()" /> -->
        <intercept-url pattern="/weixin/**" access="permitAll"/>
        <custom-filter before="FORM_LOGIN_FILTER" ref="jwtAuthenticationFilter"/>
        <form-login username-parameter="phone" authentication-success-handler-ref="authenticationSuccessHandler"
                    authentication-failure-handler-ref="authenticationFailuerHandler"/>
    </http>

    <beans:bean id="jwtAuthenticationFilter"
                class="cn.huiyunche.commons.security.JwtAuthenicationFilter">
        <beans:constructor-arg value="${secure.key}"/>
    </beans:bean>

    <authentication-manager alias="authenticationManager">
        <authentication-provider user-service-ref="userDetailsService">
            <password-encoder ref="passwordEncoder"/>
        </authentication-provider>
    </authentication-manager>

    <beans:bean name="passwordEncoder" class="org.springframework.security.authentication.encoding.Md5PasswordEncoder"/>

    <beans:bean name="userDetailsService" class="cn.huiyunche.commons.security.dao.UserSecurityDao">
        <beans:property name="jdbcTemplate" ref="jdbcTemplate"/>
    </beans:bean>

    <beans:bean name="jwtAuthenticationEntryPoint"
                class="cn.huiyunche.commons.security.JwtAuthenticationEntryPoint"/>

    <beans:bean name="authenticationSuccessHandler"
                class="cn.huiyunche.commons.security.JwtAuthenticationSuccessHandler">
        <beans:constructor-arg value="${secure.key}"/>
    </beans:bean>

    <beans:bean name="authenticationFailuerHandler"
                class="cn.huiyunche.commons.security.JwtAuthenticationFailureHandler"/>


    <beans:bean id="applicationContext-security" class="org.apache.axis2.extensions.spring.receivers.ApplicationContextHolder" />
    <beans:bean id="wmsBusinessServiceImpl" class="com.unlcn.ils.wms.api.webservice.server.WmsBusinessServiceImpl"/>
</beans:beans>


然后写自己的Service服务端实现类。

这里需要注意jar版本的问题,可能对于java8的特性,需要高版本的jar。

对于一些异常首先要解决jar包的版本。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值