日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 前端技术 > javascript >内容正文

javascript

Springboot集成axis1.4

發(fā)布時間:2024/9/27 javascript 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Springboot集成axis1.4 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

文章目錄

            • 1. 引入依賴
            • 2. Servlet
            • 3.接口
            • 4.實現(xiàn)類
            • 5.配置工廠
            • 6.啟動類
            • 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.實現(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.啟動類
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目錄

<?xml version="1.0" encoding="UTF-8"?> <deployment xmlns="http://xml.apache.org/axis/wsdd/"xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"><handler type="java:org.apache.axis.handlers.http.URLMapper"name="URLMapper" /><!--要告訴別人的接口名--><service name="HelloServiceImpl" provider="java:RPC"><!--這個是 實現(xiàn)類--><parameter name="className" value="com.example.demo.service.impl.HelloServiceImpl" /><!--這是是暴露的方法名 比如可以值暴露一個--><parameter name="allowedMethods" value="sayHello" /><!--這是是暴露的方法名 也可以用* 表示暴露全部的public方法--><!--<parameter name="allowedMethods" value="*" />--></service><transport name="http"><requestFlow><handler type="URLMapper" /></requestFlow></transport></deployment>
8. 訪問

http://localhost:8080/services/HelloServiceImpl?wsdl

總結(jié)

以上是生活随笔為你收集整理的Springboot集成axis1.4的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。