码迷,mamicode.com
首页 > Web开发 > 详细

axis调用webservice客户端开发

时间:2015-12-15 11:58:57      阅读:128      评论:0      收藏:0      [点我收藏+]

标签:

第一步:wsdl2Java.bat文件编写  

Axis_Lib表示依赖的jar包路径
Output_Path表示生成的class路径
Package包名  还需要手动更改
-p %Package%表示webservice服务端名称  (注:http://localhost/CHIMSWEB/services/ChimsAppImplService?wsdl)
set Axis_Lib="E:\Workspaces\MyEclipse Professional\CHIMS_20151008\WebRoot\WEB-INF\lib"
set Java_Cmd=java -Djava.ext.dirs=%Axis_Lib%
set Output_Path="E:\Workspaces\MyEclipse Professional\CHIMS_20151008\src\com\zhongzhi\chims\service\App\client"
set Package=com.zhongzhi.chims.service.App.client
%Java_Cmd% org.apache.axis.wsdl.WSDL2Java -o %Output_Path% -p %Package% http://localhost/CHIMSWEB/services/ChimsAppImplService?wsdl
pause;

 

第二步:引入依赖jar包 技术分享

第三步:运行wsdl2Java.bat批处理文件就可以生成代码,调用webservice了

package com.zhongzhi.chims.service.zhongkang;

import java.io.StringReader;
import java.net.URL;
import java.util.Iterator;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller;

import org.dom4j.Document;
import org.dom4j.DocumentHelper;

import com.zhongzhi.chims.service.zhongkang.Client.BeinuoInterface;
import com.zhongzhi.chims.service.zhongkang.Client.BeinuoServerService;
import com.zhongzhi.chims.service.zhongkang.Client.BeinuoServerServiceLocator;
import com.zhongzhi.common.func.BlankUtil;

public class TestTcfWebService {
	public static void main(String[] args) {
		BeinuoServerService service=null;
		
		BeinuoInterface server=null;
		
		System.out.println("connect....");
		
          //服务端地址 String strPortAddress = "http://localhost//services/reportServer"; URL portAddress; try { portAddress = new URL(strPortAddress); // 得到客户端服务. service = new BeinuoServerServiceLocator(); // 得到客户端stub. server = service.getBeinuoServerPort(portAddress); // 测试服务方法. String resultStr = server.getTCHFinfo("310101197001044432","001011","张健","123456"); } catch (Exception e) { e.printStackTrace(); } } }

  

 

axis调用webservice客户端开发

标签:

原文地址:http://www.cnblogs.com/ph123/p/5047659.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!