• axis调用webservice客户端开发


    第一步:wsdl2Java.bat文件编写  

    Axis_Lib表示依赖的jar包路径
    Output_Path表示生成的class路径
    Package包名  还需要手动更改
    -p %Package%表示webservice服务端名称  (注:http://localhost/CHIMSWEB/services/ChimsAppImplService?wsdl)
    set Axis_Lib="E:WorkspacesMyEclipse ProfessionalCHIMS_20151008WebRootWEB-INFlib"
    set Java_Cmd=java -Djava.ext.dirs=%Axis_Lib%
    set Output_Path="E:WorkspacesMyEclipse ProfessionalCHIMS_20151008srccomzhongzhichimsserviceAppclient"
    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(); } } }

      

  • 相关阅读:
    MySQL优化---主从复制
    MySQL性能优化---优化方案
    MySQL性能优化---索引
    MySQL性能优化---定位慢查询
    Linux开机启动过程详解
    naginx
    Git搭建
    脚本中特殊字符
    Shell脚本
    简单Shell脚本(实例)
  • 原文地址:https://www.cnblogs.com/ph123/p/5047659.html
Copyright © 2020-2023  润新知