當(dāng)前位置:
首頁(yè) >
前端技术
> javascript
>内容正文
javascript
Springboot集成axis1.4
生活随笔
收集整理的這篇文章主要介紹了
Springboot集成axis1.4
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
文章目錄
- 1. 引入依賴
- 2. Servlet
- 3.接口
- 4.實(shí)現(xiàn)類
- 5.配置工廠
- 6.啟動(dòng)類
- 7. server-config.wsdd
- 8. 訪問
1. 引入依賴
<!--axis start --><dependency><groupId>org.apache.axis</groupId><artifactId>axis</artifactId><version>1.4</version></dependency><dependency><groupId>axis</groupId><artifactId>axis-jaxrpc</artifactId><version>1.4</version></dependency><dependency><groupId>commons-discovery</groupId><artifactId>commons-discovery</artifactId><version>0.2</version></dependency><dependency><groupId>wsdl4j</groupId><artifactId>wsdl4j</artifactId><version>1.6.3</version></dependency><!--axis end -->2. Servlet
package com.example.demo;import org.apache.axis.transport.http.AxisServlet;@javax.servlet.annotation.WebServlet(urlPatterns = "/services/*",loadOnStartup = 1,name = "AxisServlet" ) public class WebServlet extends AxisServlet {}3.接口
package com.example.demo.service;public interface HelloService {public String sayHello(String info); }4.實(shí)現(xiàn)類
package com.example.demo.service.impl;import com.example.demo.service.HelloService; import org.springframework.stereotype.Service;@Service public class HelloServiceImpl implements HelloService {/*** http://localhost:8080/services/HelloServiceImpl?wsdl** @param info* @return*/@Overridepublic String sayHello(String info) {return "sayHello:" + info;} }5.配置工廠
直接復(fù)制即可
package com.example.demo;import org.apache.axis.AxisProperties; import org.apache.axis.ConfigurationException; import org.apache.axis.EngineConfiguration; import org.apache.axis.EngineConfigurationFactory; import org.apache.axis.components.logger.LogFactory; import org.apache.axis.configuration.EngineConfigurationFactoryDefault; import org.apache.axis.configuration.FileProvider; import org.apache.axis.server.AxisServer; import org.apache.axis.utils.ClassUtils; import org.apache.axis.utils.Messages; import org.apache.commons.logging.Log;import javax.servlet.ServletConfig; import java.io.InputStream;public class EngineConfigurationFactoryServletextends EngineConfigurationFactoryDefault {protected static Log log =LogFactory.getLog(EngineConfigurationFactoryServlet.class.getName());private ServletConfig cfg;public static EngineConfigurationFactory newFactory(Object param) {return (param instanceof ServletConfig)? new EngineConfigurationFactoryServlet((ServletConfig) param): null;}protected EngineConfigurationFactoryServlet(ServletConfig conf) {super();this.cfg = conf;}public EngineConfiguration getServerEngineConfig() {return getServerEngineConfig(cfg);}private static EngineConfiguration getServerEngineConfig(ServletConfig cfg) {// Respect the system property setting for a different config fileString configFile = cfg.getInitParameter(OPTION_SERVER_CONFIG_FILE);if (configFile == null)configFile =AxisProperties.getProperty(OPTION_SERVER_CONFIG_FILE);if (configFile == null) {configFile = SERVER_CONFIG_FILE;}String appWebInfPath = "/WEB-INF";//由于部署方式變更為jar部署,此處不可以使用改方式獲取路徑 // ServletContext ctx = cfg.getServletContext(); // String realWebInfPath = ctx.getRealPath(appWebInfPath);FileProvider config = null;String realWebInfPath = EngineConfigurationFactoryServlet.class.getResource(appWebInfPath).getPath();InputStream iss = ClassUtils.getResourceAsStream(EngineConfigurationFactoryServlet.class, appWebInfPath + "/" + SERVER_CONFIG_FILE);if (iss != null) {config = new FileProvider(iss);}if (config == null) {log.error(Messages.getMessage("servletEngineWebInfError03", ""));}if (config == null && realWebInfPath != null) {try {config = new FileProvider(realWebInfPath, configFile);} catch (ConfigurationException e) {log.error(Messages.getMessage("servletEngineWebInfError00"), e);}}if (config == null) {log.warn(Messages.getMessage("servletEngineWebInfWarn00"));try {InputStream is =ClassUtils.getResourceAsStream(AxisServer.class,SERVER_CONFIG_FILE);config = new FileProvider(is);} catch (Exception e) {log.error(Messages.getMessage("servletEngineWebInfError02"), e);}}return config;} }6.啟動(dòng)類
package com.example.demo;import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.web.servlet.ServletComponentScan;@SpringBootApplication @ServletComponentScan //掃描自定義的WebFilter和WebListener,否則無法掃描到 public class DemoApplication {public static void main(String[] args) {SpringApplication.run(DemoApplication.class, args);}}7. server-config.wsdd
創(chuàng)建webapp/WEB-INF目錄
8. 訪問
http://localhost:8080/services/HelloServiceImpl?wsdl
總結(jié)
以上是生活随笔為你收集整理的Springboot集成axis1.4的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: liunx JMeter 进行压力测试
- 下一篇: SpringBoot配置文件 【自定义配