axis2 写webservice服务 和 被调用 的整个过程

来源:互联网 发布:it行业工作总结 编辑:程序博客网 时间:2024/05/22 08:05

 一:准备工作

          maven pom配置


<properties><jdbc.driver.groupId>com.oracle</jdbc.driver.groupId><jdbc.driver.artifactId>ojdbc14</jdbc.driver.artifactId><jdbc.driver.version>10.2.0</jdbc.driver.version><!-- 10.2.0.3.0 --><!-- 主要依赖库的版本定义 --><!-- <meteor.version>3.0.1</meteor.version> --><meteor.release.version></meteor.release.version><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><axis2.version>1.5.5</axis2.version></properties><!-- axis2 --><dependency><groupId>org.apache.axis2</groupId><artifactId>axis2</artifactId><version>${axis2.version}</version></dependency><dependency><groupId>org.apache.axis2</groupId><artifactId>axis2-aar-maven-plugin</artifactId><version>${axis2.version}</version></dependency><dependency><groupId>org.apache.axis2</groupId><artifactId>axis2-adb</artifactId><version>${axis2.version}</version></dependency><dependency><groupId>org.apache.axis2</groupId><artifactId>axis2-adb-codegen</artifactId><version>${axis2.version}</version></dependency><dependency><groupId>org.apache.axis2</groupId><artifactId>axis2-ant-plugin</artifactId><version>${axis2.version}</version></dependency><dependency><groupId>org.apache.axis2</groupId><artifactId>axis2-clustering</artifactId><version>${axis2.version}</version></dependency><dependency><groupId>org.apache.axis2</groupId><artifactId>axis2-codegen</artifactId><version>${axis2.version}</version></dependency><dependency><groupId>org.apache.axis2</groupId><artifactId>axis2-integration</artifactId><version>${axis2.version}</version></dependency><dependency><groupId>org.apache.axis2</groupId><artifactId>axis2-java2wsdl</artifactId><version>${axis2.version}</version></dependency><dependency><groupId>org.apache.axis2</groupId><artifactId>axis2-java2wsdl-maven-plugin</artifactId><version>${axis2.version}</version></dependency><dependency><groupId>org.apache.axis2</groupId><artifactId>axis2-jaxbri</artifactId><version>${axis2.version}</version></dependency><dependency><groupId>org.apache.axis2</groupId><artifactId>axis2-jaxws</artifactId><version>${axis2.version}</version></dependency><dependency><groupId>org.apache.axis2</groupId><artifactId>axis2-jaxws-integration</artifactId><version>${axis2.version}</version></dependency><dependency><groupId>org.apache.axis2</groupId><artifactId>axis2-jibx</artifactId><version>${axis2.version}</version></dependency><dependency><groupId>org.apache.axis2</groupId><artifactId>axis2-json</artifactId><version>${axis2.version}</version></dependency><dependency><groupId>org.apache.axis2</groupId><artifactId>axis2-kernel</artifactId><version>${axis2.version}</version></dependency><dependency><groupId>org.apache.axis2</groupId><artifactId>axis2-mar-maven-plugin</artifactId><version>${axis2.version}</version></dependency><dependency><groupId>org.apache.axis2</groupId><artifactId>axis2-metadata</artifactId><version>${axis2.version}</version></dependency><dependency><groupId>org.apache.axis2</groupId><artifactId>axis2-mtompolicy</artifactId><version>${axis2.version}</version></dependency><dependency><groupId>org.apache.axis2</groupId><artifactId>axis2-repo-maven-plugin</artifactId><version>${axis2.version}</version></dependency><dependency><groupId>org.apache.axis2</groupId><artifactId>axis2-resource-bundle</artifactId><version>${axis2.version}</version></dependency><dependency><groupId>org.apache.axis2</groupId><artifactId>axis2-saaj</artifactId><version>${axis2.version}</version></dependency><dependency><groupId>org.apache.axis2</groupId><artifactId>axis2-soapmonitor-servlet</artifactId><version>${axis2.version}</version></dependency><dependency><groupId>org.apache.axis2</groupId><artifactId>axis2-spring</artifactId><version>${axis2.version}</version></dependency><dependency><groupId>org.apache.axis2</groupId><artifactId>axis2-transport-http</artifactId><version>${axis2.version}</version></dependency><dependency><groupId>org.apache.axis2</groupId><artifactId>axis2-transport-local</artifactId><version>${axis2.version}</version></dependency><dependency><groupId>org.apache.axis2</groupId><artifactId>axis2-wsdl2code-maven-plugin</artifactId><version>${axis2.version}</version></dependency><dependency><groupId>org.apache.axis2</groupId><artifactId>axis2-xmlbeans</artifactId><version>${axis2.version}</version></dependency><dependency><groupId>org.apache.axis2</groupId><artifactId>org.apache.axis2.osgi</artifactId><version>${axis2.version}</version></dependency>


二:操作

      将写好的业务逻辑。

    其中解析和包装xml可以使用 dom4j。

  1:生成xml 例如

    

/** * @Title: toXml * @Description: TODO(这里用一句话描述这个方法的作用) * @return */public String toXml() {Document document = DocumentHelper.createDocument();// rootElement eleSearchResult = document.addElement("SearchResult");String reason = this.getErrorValue();if (reason == null || "".equals(reason.trim())) {Map<String, Object> map = this.beanMap();for (Entry<String, Object> enter : map.entrySet()) {eleSearchResult = XmlUtils.addElement(eleSearchResult,enter.getKey(), enter.getValue());}} else {eleSearchResult = XmlUtils.addElement(eleSearchResult, "Reason",reason);}String xmlData = document.asXML();return xmlData;}

2:解析xml例如

public static void xmltodate(SearchZQInfoResult searchZQInfoResult, String xmlData) {Document document = null;String reason = null;document = DocumentHelper.parseText(xmlData);Element root = document.getRootElement();Element elementResultContent = (Element) root.selectSingleNode("ResultContent");}

      在图中的services下的info文件夹 需要  用jar cvf  info.aar .    进行打包。

      注:如果接口使用对象为参数。请注意序列化好对象。


	
				
		
原创粉丝点击