设为首页 加入收藏

TOP

springboot整合axis1.4搭建服务端(一)
2019-09-03 01:24:13 】 浏览:51
Tags:springboot 整合 axis1.4 搭建 服务

前言

最近公司要开发个接口,要用webservices接口实现,而且使用的是axis1.4框架,webservices和axis这两个东西我之前都没接触过,而且axis1.4这个框架06年就不再维护了,没办法,客户就是上帝。上网查了一圈,基本都是spring整合axis的,而公司用的是springboot,比较头疼,在此记录下搭建过程。

一、引入依赖

 1 <dependency>
 2 <groupId>org.apache.axis</groupId>
 3 <artifactId>axis</artifactId>
 4 <version>1.4</version>
 5 </dependency>
 6 
 7 <dependency>
 8 <groupId>axis</groupId>
 9 <artifactId>axis-jaxrpc</artifactId>
10 <version>1.4</version>
11 </dependency>
12 
13 <dependency>
14 <groupId>commons-discovery</groupId>
15 <artifactId>commons-discovery</artifactId>
16 <version>0.2</version>
17 </dependency>
18 <dependency>
19 <groupId>wsdl4j</groupId>
20 <artifactId>wsdl4j</artifactId>
21 <version>1.6.3</version>
22 </dependency>

二、写个接口以及实现类

接口:

1 public interface HelloService {
2     public String sayHello(String info);
3  
4 }

实现类:

1 public class HelloServiceImpl implements HelloService {
2     public String sayHello(String info) {
3         return "sayHello:"+info;
4     }
5 }

三、创建资源文件server-config.wsdd

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <deployment xmlns="http://xml.apache.org/axis/wsdd/"
 3     xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
 4     <handler type="java:org.apache.axis.handlers.http.URLMapper"
 5         name="URLMapper" />
 6     
 7     <!--要告诉别人的接口名-->
 8     <service name="HelloServiceImpl" provider="java:RPC">
 9         <!--这个是 实现类-->
10         <parameter name="className" value="com.codefish.javalab.ws.server.HelloServiceImpl" />
11         <!--这是是暴露的方法名   比如可以值暴露一个-->
12         <parameter name="allowedMethods" value="sayHello" />
13         <!--这是是暴露的方法名   也可以用* 表示暴露全部的public方法-->
14         <!--<parameter name="allowedMethods" value="*" />-->
15     </service>
16 
17     <transport name="http">
18         <requestFlow>
19             <handler type="URLMapper" />
20         </requestFlow>
21     </transport>
22 
23 </deployment>

四、添加servlet过滤规则

新建com.example.servlet.WebServlet,继承AxisServlet。

 1     package com.example.servlet;
 2     import org.apache.axis.transport.http.AxisServlet;
 3     @javax.servlet.annotation.WebServlet(
 4             urlPatterns =  "/services/*",
 5             loadOnStartup = 1,
 6             name = "AxisServlet"
 7     )
 8     public class WebServlet extends AxisServlet {
 9            
10     }

五、重写Axis的配置工厂信息

因为我想要以jar包形式发布,所以需要重写EngineConfigurationFactory类,否则会访问不到。新建org.apache.axis.configuration.EngineConfigurationFactoryServlet,继承EngineConfigurationFactoryDefault。更改的是getServerEngineConfig(ServletConfig cfg)方法。(注意:该类需要放在org.apache.axis.configuration包下,我尝试放在其他路径下无效,如有大神知道,还望告知

  1 /*
  2  * Copyright 2002-2004 The Apache Software Foundation.
  3  * 
  4  * Licensed under the Apache License, Version 2.0 (the "License");
  5  * you may not use this file except in compliance with the License.
  6  * You may obtain a copy of the Lic
首页 上一页 1 2 3 4 下一页 尾页 1/4/4
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇终端参数上报后,平台通过tcp协议.. 下一篇java实现文字转语音功能(仅Window..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目