最近 項目對接 webservice,要求SOAP 標准是1.1,然后在axis 和 spring ws 和 cxf 之間進行選擇,然后axis 可以自定義服務,然后隨tomcat啟動發布,spring ws 也研究了下,感覺稍微有點復雜,cxf 發布感覺不是特別好管理,但是集成spring 特別簡單,發布的時候可以指定任意端口, 最終呢,考慮良久,還是選擇一個成熟穩定點的吧,最終選擇了Axis1.4, 然后網上找資料,集成到了springboot項目中,稍微麻煩點的是有兩個配置類,這個其實也是參考網上來的,然后代碼貼出來,
public class SpringBootEngineConfigurationFactoryServlet extends EngineConfigurationFactoryDefault {
protected static Log log = LogFactory.getLog(SpringBootEngineConfigurationFactoryServlet.class.getName());
private ServletConfig cfg;
/**
* Creates and returns a new EngineConfigurationFactory. If a factory cannot be
* created, return 'null'.
*
* The factory may return non-NULL only if: - it knows what to do with the param
* (param instanceof ServletContext) - it can find it's configuration
* information
*
* @see org.apache.axis.configuration.EngineConfigurationFactoryFinder
*/
public static EngineConfigurationFactory newFactory(Object param) {
/**
* Default, let this one go through if we find a ServletContext.
*
* The REAL reason we are not trying to make any decision here is because it's
* impossible (without refactoring FileProvider) to determine if a *.wsdd file
* is present or not until the configuration is bound to an engine.
*
* FileProvider/EngineConfiguration pretend to be independent, but they are
* tightly bound to an engine instance...
*/
return (param instanceof ServletConfig) ? new SpringBootEngineConfigurationFactoryServlet((ServletConfig) param) : null;
}
/**
* Create the default engine configuration and detect whether the user has
* overridden this with their own.
*/
protected SpringBootEngineConfigurationFactoryServlet(ServletConfig conf) {
super();
this.cfg = conf;
}
/**
* Get a default server engine configuration.
*
* @return a server EngineConfiguration
*/
@Override
public EngineConfiguration getServerEngineConfig() {
return getServerEngineConfig(cfg);
}
/**
* Get a default server engine configuration in a servlet environment.
*
* @param cfg
* a ServletContext
* @return a server EngineConfiguration
*/
private static EngineConfiguration getServerEngineConfig(ServletConfig cfg) {
//ServletContext ctx = cfg.getServletContext();
// Respect the system property setting for a different config file
String configFile = cfg.getInitParameter(OPTION_SERVER_CONFIG_FILE);
if (configFile == null)
configFile = AxisProperties.getProperty(OPTION_SERVER_CONFIG_FILE);
if (configFile == null) {
configFile = SERVER_CONFIG_FILE;
}
/**
* Flow can be confusing. Here is the logic: 1) Make all attempts to open
* resource IF it exists - If it exists as a file, open as file (r/w) - If not a
* file, it may still be accessable as a stream (r) (env will handle security
* checks). 2) If it doesn't exist, allow it to be opened/created
*
* Now, the way this is done below is: a) If the file does NOT exist, attempt to
* open as a stream (r) b) Open named file (opens existing file, creates if not
* avail).
*/
/*
* Use the WEB-INF directory (so the config files can't get snooped by a
* browser)
*/
FileProvider config = null;
//String realWebInfPath = ctx.getRealPath(appWebInfPath);
String appWebInfPath = "/WEB-INF/classes/";
//由於部署方式變更為jar部署,此處不可以使用改方式獲取路徑
ServletContext ctx = cfg.getServletContext();
String realWebInfPath = ctx.getRealPath(appWebInfPath);
log.info("支持spring boot war 啟動方式,獲取wsdd . realWebInfPath = " + realWebInfPath);
//FileProvider config = null;
// String appWebInfPath = "/";
// String realWebInfPath = SpringBootEngineConfigurationFactoryServlet.class.getResource(appWebInfPath).getPath();
// log.info("支持spring boot jar 啟動方式,獲取wsdd . realWebInfPath = " + realWebInfPath);
/**
* If path/file doesn't exist, it may still be accessible as a resource-stream
* (i.e. it may be packaged in a JAR or WAR file).
*/
if (realWebInfPath == null || !(new File(realWebInfPath, configFile)).exists()) {
//修改目錄
String name = appWebInfPath + configFile;
//修改,讀取數據
InputStream is = ClassUtils.getResourceAsStream(SpringBootEngineConfigurationFactoryServlet.class, name);
if (is != null) {
// FileProvider assumes responsibility for 'is':
// do NOT call is.close().
config = new FileProvider(is);
}
if (config == null) {
log.error(Messages.getMessage("servletEngineWebInfError03", name));
}
}
/**
* Couldn't get data OR file does exist. If we have a path, then attempt to
* either open the existing file, or create an (empty) file.
*/
if (config == null && realWebInfPath != null) {
try {
config = new FileProvider(realWebInfPath, configFile);
} catch (ConfigurationException e) {
log.error(Messages.getMessage("servletEngineWebInfError00"), e);
}
}
/**
* Fall back to config file packaged with AxisEngine
*/
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;
}
}
微稍注意的就是這個地方:
因為springboot 項目的resources打包之后都在classes目錄下,所以達成war包的時候要配置成 /WEB-INF/classes目錄下,如果是jar 方式的話,貌似直接是/WEB-INF/ 就行了,這個得看打包之后的配置文件放置的目錄了,感興趣的朋友可以自己去試驗下,然后springboot配置servlet 代碼如下:
@Configuration public class AutoAxisConfiguration { @Bean public ServletRegistrationBean<AxisServlet> axisServlet() { ServletRegistrationBean<AxisServlet> servlet = new ServletRegistrationBean<AxisServlet>(); servlet.setServlet(new AxisServlet()); servlet.addUrlMappings("/services/*"); servlet.setName("AxisServlet"); servlet.setLoadOnStartup(1); //設置引擎 //與官方提供默認引擎區別:查找wsdd位置不同。一個是springboot位置,一個是WEB-INF位置(war) System.setProperty(EngineConfigurationFactory.SYSTEM_PROPERTY_NAME,"com.cgd.ws.config.SpringBootEngineConfigurationFactoryServlet"); return servlet; } }
接下來就是配置wsdd文件了,這個網上也有現成的模板,但是都是最簡潔的,但是因為我們系統是和外部系統進行對接,所以要求進行加密操作,然后當時也是自己查文檔,進行百度,然后配置了用戶名密碼,現在統一把代碼粘貼如下:
package com.cgd.material.configuration; import org.apache.axis.MessageContext; import org.apache.axis.components.logger.LogFactory; import org.apache.axis.security.AuthenticatedUser; import org.apache.axis.security.simple.SimpleAuthenticatedUser; import org.apache.axis.security.simple.SimpleSecurityProvider; import org.apache.axis.utils.Messages; import org.apache.commons.logging.Log; import java.io.File; import java.io.FileReader; import java.io.LineNumberReader; import java.util.HashMap; import java.util.StringTokenizer; /** * @Description 修改初始化方法,因尋找密碼路徑為WEB-INF/users.lst,先變更為WEB-INF/classes/users.lst * @Author huluy * @Date 2019/5/16 15:22 **/ public class WsExtendedSimpleSecurityProvider extends SimpleSecurityProvider { public static final String NOUSERNAME = "nousername"; public static final String DEFAULTPASSWORD = "deX3vxNNb^RZ#aSM9o8A"; protected static Log log; HashMap users = null; HashMap perms = null; boolean initialized = false; public WsExtendedSimpleSecurityProvider() { } private synchronized void initialize(MessageContext msgContext) { if (!this.initialized) { String configPath = msgContext.getStrProp("configPath"); if (configPath == null) { configPath = ""; } else { configPath = configPath + File.separator + "classes" + File.separator; } File userFile = new File(configPath + "users.lst"); if (userFile.exists()) { this.users = new HashMap(); try { FileReader fr = new FileReader(userFile); LineNumberReader lnr = new LineNumberReader(fr); String line = null; while((line = lnr.readLine()) != null) { StringTokenizer st = new StringTokenizer(line); if (st.hasMoreTokens()) { String userID = st.nextToken(); String passwd = st.hasMoreTokens() ? st.nextToken() : ""; if (log.isDebugEnabled()) { log.debug(Messages.getMessage("fromFile00", userID, passwd)); } this.users.put(userID, passwd); } } lnr.close(); } catch (Exception var10) { log.error(Messages.getMessage("exception00"), var10); return; } } this.initialized = true; } } @Override public AuthenticatedUser authenticate(MessageContext msgContext) { if (!this.initialized) { this.initialize(msgContext); } String username = msgContext.getUsername(); String password = msgContext.getPassword(); if (this.users != null) { if (log.isDebugEnabled()) { log.debug(Messages.getMessage("user00", username)); } if (this.users.containsKey(NOUSERNAME)) { return new SimpleAuthenticatedUser(NOUSERNAME); } if (username != null && !username.equals("") && this.users.containsKey(username)) { String valid = (String)this.users.get(username); if (log.isDebugEnabled()) { log.debug(Messages.getMessage("password00", password)); } if (valid.length() > 0 && !valid.equals(password)) { return null; } else { if (log.isDebugEnabled()) { log.debug(Messages.getMessage("auth00", username)); } return new SimpleAuthenticatedUser(username); } } else { return null; } } else { return null; } } public HashMap getUsers(MessageContext msgContext) { if (users == null) { this.initialize(msgContext); } return users; } static { log = LogFactory.getLog(WsExtendedSimpleSecurityProvider.class.getName()); } }
package com.cgd.material.configuration; import org.apache.axis.AxisFault; import org.apache.axis.MessageContext; import org.apache.axis.handlers.SimpleAuthenticationHandler; import org.apache.axis.security.AuthenticatedUser; import org.apache.axis.security.SecurityProvider; import org.apache.axis.utils.Messages; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.w3c.dom.Element; import java.util.HashMap; /** * @Description 重寫提供權限的方法,修改為自定義的SecurityProvider * @Author huluy * @Date 2019/5/16 15:35 **/ public class WsExtendSimpleAuthenticationHandler extends SimpleAuthenticationHandler { protected static Log log = LogFactory.getLog(WsExtendSimpleAuthenticationHandler.class.getName()); public WsExtendSimpleAuthenticationHandler() { } @Override public void invoke(MessageContext msgContext) throws AxisFault { if (log.isDebugEnabled()) { log.debug("Enter: WsExtendSimpleAuthenticationHandler::invoke"); } SecurityProvider provider = (SecurityProvider)msgContext.getProperty("securityProvider"); if (provider == null) { // 修改為自定義的wsSecurityProvider WsExtendedSimpleSecurityProvider wsExtendedSimpleSecurityProvider = new WsExtendedSimpleSecurityProvider(); provider = wsExtendedSimpleSecurityProvider; msgContext.setProperty("securityProvider", provider); // 配置是否添加用戶名密碼配置 HashMap usersLsts = wsExtendedSimpleSecurityProvider.getUsers(msgContext); // 如果配置用戶名密碼中含有: nousername nousername 表示該用戶直接可以通過訪問 if (usersLsts != null && usersLsts.containsKey(WsExtendedSimpleSecurityProvider.NOUSERNAME)) { msgContext.setUsername(WsExtendedSimpleSecurityProvider.NOUSERNAME); msgContext.setPassword(WsExtendedSimpleSecurityProvider.DEFAULTPASSWORD); } } if (provider != null) { String userID = msgContext.getUsername(); if (log.isDebugEnabled()) { log.debug(Messages.getMessage("user00", userID)); } if (userID == null || userID.equals("")) { throw new AxisFault("Server.Unauthenticated", Messages.getMessage("cantAuth00", userID), (String)null, (Element[])null); } String passwd = msgContext.getPassword(); if (log.isDebugEnabled()) { log.debug(Messages.getMessage("password00", passwd)); } AuthenticatedUser authUser = ((SecurityProvider)provider).authenticate(msgContext); if (authUser == null) { throw new AxisFault("Server.Unauthenticated", Messages.getMessage("cantAuth01", userID), (String)null, (Element[])null); } if (log.isDebugEnabled()) { log.debug(Messages.getMessage("auth00", userID)); } msgContext.setProperty("authenticatedUser", authUser); } if (log.isDebugEnabled()) { log.debug("Exit: WsExtendSimpleAuthenticationHandler::invoke"); } } }
其實都沒有特別動代碼,主要是繼承了axis的 父類,然后在wsdd文件中配置了復雜對象和密碼配置
<deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"> <globalConfiguration> <parameter name="adminPassword" value="admin"/> <parameter name="axis.servicesPath" value="/services/"/> <!--<parameter name="attachments.Directory" value="c:\temp\attachments"/>--> <parameter name="sendMultiRefs" value="false"/> <parameter name="sendXsiTypes" value="true"/> <parameter name="attachments.implementation" value="org.apache.axis.attachments.AttachmentsImpl"/> <parameter name="sendXMLDeclaration" value="true"/> <parameter name="enable2DArrayEncoding" value="true"/> <parameter name="dotNetSoapEncFix" value="true"/> <parameter name="disablePrettyXML" value="true"/> <parameter name="enableNamespacePrefixOptimization" value="false"/> <parameter name="emitAllTypesInWSDL" value="true"/> <requestFlow> <handler name="Authenticate" type="java:com.cgd.material.configuration.WsExtendSimpleAuthenticationHandler"/> </requestFlow> <requestFlow> <handler type="java:org.apache.axis.handlers.JWSHandler"> <parameter name="scope" value="session"/> </handler> <handler type="java:org.apache.axis.handlers.JWSHandler"> <parameter name="scope" value="request"/> <parameter name="extension" value=".jwr"/> </handler> </requestFlow> </globalConfiguration> <service name="AdminService" provider="java:MSG"> <parameter name="allowedMethods" value="AdminService"/> <parameter name="enableRemoteAdmin" value="false"/> <parameter name="className" value="org.apache.axis.utils.Admin"/> <namespace>http://xml.apache.org/axis/wsdd/</namespace> </service> <service name="Version" provider="java:RPC"> <parameter name="allowedMethods" value="getVersion"/> <parameter name="className" value="org.apache.axis.Version"/> </service> <!-- 自定義發布服務 start --> <!-- 測試服務 --> <service name="helloWorldTestService" provider="java:RPC"> <parameter name="className" value="com.cgd.material.server.WsHelloWorldTestService"/> <parameter name="allowedMethods" value="*"/> </service> <!-- 測試 數組對象 服務 --> <service name="mdmMasterdataArrayTestService" provider="java:RPC" style="document" use="literal"> <parameter name="className" value="com.cgd.material.server.MdmMasterdataArrayTestService"/> <parameter name="allowedMethods" value="*"/> <beanMapping languageSpecificType="java:com.cgd.material.bo.mdm.MATERIAL_LOG_STATUS_ARRAY" qname="ns:materialLogStatusArray" xmlns:ns="urn:mdmMasterdataArrayReciveService"/> <typeMapping xmlns:ns="ns:mdmMasterdataArrayReciveService" qname="ns:materialLogStatusArray" languageSpecificType="java:com.cgd.material.bo.mdm.MATERIAL_LOG_STATUS_ARRAY" serializer="org.apache.axis.encoding.ser.DocumentSerializerFactory" deserializer="org.apache.axis.encoding.ser.DocumentDeserializerFactory" encodingStyle="" /> <beanMapping languageSpecificType="java:com.cgd.material.bo.mdm.MATERIAL_LOG_STAUS" qname="ns:materialLogStatus" xmlns:ns="urn:mdmMasterdataArrayReciveService"/> <typeMapping xmlns:ns="ns:mdmMasterdataArrayReciveService" qname="ns:materialLogStatus" languageSpecificType="java:com.cgd.material.bo.mdm.MATERIAL_LOG_STAUS" serializer="org.apache.axis.encoding.ser.DocumentSerializerFactory" deserializer="org.apache.axis.encoding.ser.DocumentDeserializerFactory" encodingStyle="" /> <beanMapping languageSpecificType="java:com.cgd.material.bo.mdm.MATERIAL" qname="ns:material" xmlns:ns="urn:mdmMasterdataArrayReciveService"/> <typeMapping xmlns:ns="ns:mdmMasterdataArrayReciveService" qname="ns:material" languageSpecificType="java:com.cgd.material.bo.mdm.MATERIAL" serializer="org.apache.axis.encoding.ser.DocumentSerializerFactory" deserializer="org.apache.axis.encoding.ser.DocumentDeserializerFactory" encodingStyle="" /> <beanMapping languageSpecificType="java:com.cgd.material.bo.mdm.ATTRIBUTE_INFO" qname="ns:attributeInfo" xmlns:ns="urn:mdmMasterdataArrayReciveService"/> <typeMapping xmlns:ns="ns:mdmMasterdataArrayReciveService" qname="ns:attributeInfo" languageSpecificType="java:com.cgd.material.bo.mdm.ATTRIBUTE_INFO" serializer="org.apache.axis.encoding.ser.DocumentSerializerFactory" deserializer="org.apache.axis.encoding.ser.DocumentDeserializerFactory" encodingStyle="" /> <beanMapping languageSpecificType="java:com.cgd.material.bo.MdmInterfaceRspBO" qname="ns:mdmInterfaceRspBO" xmlns:ns="urn:mdmMasterdataArrayReciveService"/> <typeMapping xmlns:ns="ns:mdmMasterdataArrayReciveService" qname="ns:mdmInterfaceRspBO" languageSpecificType="java:com.cgd.material.bo.MdmInterfaceRspBO" serializer="org.apache.axis.encoding.ser.DocumentSerializerFactory" deserializer="org.apache.axis.encoding.ser.DocumentDeserializerFactory" encodingStyle="" /> <beanMapping languageSpecificType="java:com.cgd.material.bo.mdm.MDM_LOG_STAUS" qname="ns:mdmLogStatus" xmlns:ns="urn:mdmMasterdataArrayReciveService"/> <typeMapping xmlns:ns="ns:mdmMasterdataArrayReciveService" qname="ns:mdmLogStatus" languageSpecificType="java:com.cgd.material.bo.mdm.MDM_LOG_STAUS" serializer="org.apache.axis.encoding.ser.DocumentSerializerFactory" deserializer="org.apache.axis.encoding.ser.DocumentDeserializerFactory" encodingStyle="" /> <beanMapping languageSpecificType="java:com.cgd.material.bo.mdm.RESULT_TABLE" qname="ns:resultTable" xmlns:ns="urn:mdmMasterdataArrayReciveService"/> <typeMapping xmlns:ns="ns:mdmMasterdataArrayReciveService" qname="ns:resultTable" languageSpecificType="java:com.cgd.material.bo.mdm.RESULT_TABLE" serializer="org.apache.axis.encoding.ser.DocumentSerializerFactory" deserializer="org.apache.axis.encoding.ser.DocumentDeserializerFactory" encodingStyle="" /> <arrayMapping qname="ns:materialArray" type="java:com.cgd.material.bo.mdm.MATERIAL[]" xmlns:ns="urn:mdmMasterdataArrayReciveService" innerType="ns:material" encodingStyle=""/> </service> <!-- 主數據接收接口 --> <service name="mdmMasterdataReciveService" provider="java:RPC"> <parameter name="className" value="com.cgd.material.server.MdmMasterdataReciveService"/> <parameter name="allowedMethods" value="*"/> <beanMapping languageSpecificType="java:com.cgd.material.bo.mdm.MATERIAL_LOG_STAUS" qname="ns:materialLogStatus" xmlns:ns="urn:mdmMasterdataReciveService"/> <typeMapping xmlns:ns="ns:mdmMasterdataReciveService" qname="ns:materialLogStatus" languageSpecificType="java:com.cgd.material.bo.mdm.MATERIAL_LOG_STAUS" serializer="org.apache.axis.encoding.ser.BeanSerializerFactory" deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory" encodingStyle="" /> <beanMapping languageSpecificType="java:com.cgd.material.bo.mdm.MATERIAL" qname="ns:material" xmlns:ns="urn:mdmMasterdataReciveService"/> <typeMapping xmlns:ns="ns:mdmMasterdataReciveService" qname="ns:material" languageSpecificType="java:com.cgd.material.bo.mdm.MATERIAL" serializer="org.apache.axis.encoding.ser.BeanSerializerFactory" deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory" encodingStyle="" /> <beanMapping languageSpecificType="java:com.cgd.material.bo.mdm.ATTRIBUTE_INFO" qname="ns:attributeInfo" xmlns:ns="urn:mdmMasterdataReciveService"/> <typeMapping xmlns:ns="ns:mdmMasterdataReciveService" qname="ns:attributeInfo" languageSpecificType="java:com.cgd.material.bo.mdm.ATTRIBUTE_INFO" serializer="org.apache.axis.encoding.ser.BeanSerializerFactory" deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory" encodingStyle="" /> <beanMapping languageSpecificType="java:com.cgd.material.bo.MdmInterfaceRspBO" qname="ns:mdmInterfaceRspBO" xmlns:ns="urn:mdmMasterdataReciveService"/> <typeMapping xmlns:ns="ns:mdmMasterdataReciveService" qname="ns:mdmInterfaceRspBO" languageSpecificType="java:com.cgd.material.bo.MdmInterfaceRspBO" serializer="org.apache.axis.encoding.ser.BeanSerializerFactory" deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory" encodingStyle="" /> <beanMapping languageSpecificType="java:com.cgd.material.bo.mdm.MDM_LOG_STAUS" qname="ns:mdmLogStatus" xmlns:ns="urn:mdmMasterdataReciveService"/> <typeMapping xmlns:ns="ns:mdmMasterdataReciveService" qname="ns:mdmLogStatus" languageSpecificType="java:com.cgd.material.bo.mdm.MDM_LOG_STAUS" serializer="org.apache.axis.encoding.ser.BeanSerializerFactory" deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory" encodingStyle="" /> <beanMapping languageSpecificType="java:com.cgd.material.bo.mdm.RESULT_TABLE" qname="ns:resultTable" xmlns:ns="urn:mdmMasterdataReciveService"/> <typeMapping xmlns:ns="ns:mdmMasterdataReciveService" qname="ns:resultTable" languageSpecificType="java:com.cgd.material.bo.mdm.RESULT_TABLE" serializer="org.apache.axis.encoding.ser.BeanSerializerFactory" deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory" encodingStyle="" /> <arrayMapping qname="ns:materialArray" type="java:com.cgd.material.bo.mdm.MATERIAL[]" xmlns:ns="urn:mdmMasterdataReciveService" innerType="ns:material" encodingStyle=""/> </service> <!-- 自定義發布服務 end --> <handler name="URLMapper" type="java:org.apache.axis.handlers.http.URLMapper"/> <handler name="LocalResponder" type="java:org.apache.axis.transport.local.LocalResponder"/> <handler name="Authenticate" type="java:com.cgd.material.configuration.WsExtendSimpleAuthenticationHandler"/> <transport name="http" pivot="java:org.apache.axis.transport.http.CommonsHTTPSender"> <requestFlow> <handler type="URLMapper"/> <handler type="java:org.apache.axis.handlers.http.HTTPAuthHandler"/> <handler name="Authenticate" type="java:com.cgd.material.configuration.WsExtendSimpleAuthenticationHandler"/> </requestFlow> <parameter name="qs:list" value="org.apache.axis.transport.http.QSListHandler"/> <parameter name="qs:wsdl" value="org.apache.axis.transport.http.QSWSDLHandler"/> <parameter name="qs.list" value="org.apache.axis.transport.http.QSListHandler"/> <parameter name="qs.method" value="org.apache.axis.transport.http.QSMethodHandler"/> <parameter name="qs:method" value="org.apache.axis.transport.http.QSMethodHandler"/> <parameter name="qs.wsdl" value="org.apache.axis.transport.http.QSWSDLHandler"/> </transport> <transport name="local" pivot="java:org.apache.axis.transport.local.LocalSender"> <responseFlow> <handler type="LocalResponder"/> </responseFlow> </transport> <transport name="java" pivot="java:org.apache.axis.transport.java.JavaSender" /> </deployment>
這個地方是配置自定義的權限,簡單的用戶密碼驗證:
以上wsdd文件中都包含了,然后要求在resources 下 配置users.lst 文件
內容也比較簡單,就是 配置的密碼賬戶如下:
發布服務代碼為:
package com.cgd.material.server; import com.cgd.material.bo.MdmInterfaceRspBO; import com.cgd.material.bo.mdm.MATERIAL_LOG_STATUS_ARRAY; import com.cgd.material.constants.BaseConstant; import lombok.extern.slf4j.Slf4j; /** * @Description 數組對象測試 * @Author huluy * @Date 2019/8/1 17:44 **/ @Slf4j public class MdmMasterdataArrayTestService { public MdmInterfaceRspBO receiveArrayData(MATERIAL_LOG_STATUS_ARRAY material_log_status_array) { log.info("數組對象為:{}", material_log_status_array); MdmInterfaceRspBO interfaceRspBO = new MdmInterfaceRspBO(); interfaceRspBO.setZDESC(BaseConstant.WS_SUCCESS_CODE); interfaceRspBO.setZCODE("數據接收成功"); return interfaceRspBO; } }
這個是針對復雜對象的文檔模式,文檔模式要求解析的序列化和反序列化必須是:
但是如果是Bean 類型的數組定義,那么要求配置的數組對象就為:
要求所有的入參實體和出參實體必須 進行序列化,然后文檔模式和數組對象模式區別在於,在SOAP UI 調用時 文檔模式可以顯示數組對象的屬性,但是 對象數組模式呢,顯示不出來,只能顯示 對象的引用而已,截圖如下:
數組模式如下內容就不貼出來了。
以上就是這段時間對axis 1.4 的研究成果,其實 axis 1.4 已經很老舊的技術了,但是對接公司要求這么干,所以沒辦法了,只能硬着頭皮上啊, 好多東西百度 都百度不出來,后來沒辦法 然后翻牆
google ,才終於找到了一些資料,其實現在webservice 基本上用的不多了,反正以上就是自己這段時間的收獲吧,然后 具體代碼沒太整理,然后 回頭如果有需要的話再上傳吧,但是就基本上核心的代碼已經貼出來了,
好久不寫博客了,這可以算是自己 在博客園上的第一篇比較完整的博客了,ok,完事。