First step: Wsdl2java.bat file Writing
Axis_lib indicates the dependent jar package path
Output_path represents the generated class path
The package name also needs to be changed manually
-P%package% indicates WebService server name (Note: 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 ? wsdlpause;
Step two: Introduce a dependency jar package
The third step: Run wsdl2java.bat batch file can generate code, call 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 ....");
Server-side address string strportaddress = "Http://localhost//services/reportServer"; URL Portaddress;try {portaddress = new URL (strportaddress);//Get client service. Service = new Beinuoserverservicelocator ();// Get Client Stub.server = Service.getbeinuoserverport (portaddress);//test service method. String resultstr = Server.gettchfinfo ("310101197001044432", "001011", "Zhang Jian", "123456"); catch (Exception e) {e.printstacktrace ();}}}
Axis Calls WebService client development