欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

webservice生成过程

程序员文章站 2022-06-16 12:58:03
...
1、写接口方法和bean
public interface Auth {
	public Response auth(Request request);
}
public class Request {
	private int type;
	private String userid;
	private String password;
	public int getType() {
		return type;
	}
	public void setType(int type) {
		this.type = type;
	}
	public String getUserid() {
		return userid;
	}
	public void setUserid(String userid) {
		this.userid = userid;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
}
public class Response {
	private String result;
	private String resultDesc;
	public String getResult() {
		return result;
	}
	public void setResult(String result) {
		this.result = result;
	}
	public String getResultDesc() {
		return resultDesc;
	}
	public void setResultDesc(String resultDesc) {
		this.resultDesc = resultDesc;
	}
}

2、生成wdsl,使用如下bat文件,保证能根据其中Class配置找到Auth.class文件,此处是与class文件的com目录同级

  • set Axis_Lib=D:\workspace\webapps\WEB-INF\lib
  • set Java_Cmd=java -Djava.ext.dirs=%Axis_Lib%
  • set Package=com.product
  • set Class=com.product.Auth
  • set Axis_Servlet=http://auth.com/services/auth %Java_Cmd% org.apache.axis.wsdl.Java2WSDL -o Auth.wsdl -l%Axis_Servlet% -n "%Axis_Servlet%" -p%Package% "%Axis_Servlet%" %Class%


3、根据生成的wdsl文件,使用如下bat文件,生成客户端与服务端代码,客户端调用方法参见生成的**Test类,服务端实现**Impl类里的方法

  • set Axis_Lib=D:\workspace\webapps\WEB-INF\lib
  • set Java_Cmd=java -Djava.ext.dirs=%Axis_Lib%
  • set Output_Path=D:\workspace\test\javasrc
  • set Package=com.auth
  • set Axis_Servlet=http://auth.com/services/auth %Java_Cmd% org.apache.axis.wsdl.WSDL2Java -o%Output_Path% -d Session -s -S true -t -N%Axis_Servlet%=%Package% Auth.wsdl