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

 一:准备工作

          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();
		// root
		Element 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 .    进行打包。

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



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值