[webservice] axis 根据wsdl 生成 java 代码
最近维护一个老系统,数据交换部分用 axis开发的。由于要添加新的功能,打算用Apache-CXF生成客户端代码,来完成此项功能。但是,不让添加新的jar包,我去....好吧,只好用axis 来生成客户端代码。
下面的这篇博客是参考资料,在Myeclipse中添加axis的jar包。
axis.jar
commons-beanutils.jar
commons-codec-1.3.jar
commons-collections-3.0.jar
commons-configuration-1.2.jar
commons-dbcp-1.3.jar
commons-digester-1.7.jar
commons-discovery.jar
commons-fileupload-1.1.jar
commons-httpclient-3.1.jar
commons-io-1.2.jar
commons-jexl-2.0.1.jar
commons-lang-2.1.jar
commons-logging-1.2.jar
commons-logging.jar
commons-net-1.4.1.jar
commons-pool-1.5.5.jar
ecs-1.4.2.jar
jakarta-oro.jar
jakarta-regexp.jar
jaxrpc.jar
log4j-1.2.8.jar
poi-2.5.1-final-20040804.jar
velocity-1.4-rc1.jar
wsdl4j-1.5.1.jar
xml-apis.jar
比较多,可能有不必要的jar包。
以下是博客的内容:
最近在使用jboss的webservice,和AXIS2去生成AXIS 的wsdl的客户端,总是提示有问题。
注意:AXIS2和AXIS是有区别的。
实验结果是:AXIS 生成的wsdl只能使用AXIS生成wsdl的客户端。
简单记录操作过程:
http://apache.etoak.com//ws/axis/1_4/
一、下载axis-bin-1_4.zip
1. http://apache.etoak.com//ws/axis/1_4/axis-bin-1_4.zip
2.解压axis-bin-1_4.zip
二、MyEclipse中新建project
1.File ->new ->project->web project
Project name: wsdl
2.在项目中引入解压axis-bin-1_4.zip后axis-1_4/lib目录中所有的jar
3.在Run菜单中点击Run ->Java Applation
Main tab 页中Project 填写信建的项目名称wsdl
Main class 中填写 org.apache.axis.wsdl.WSDL2Java
Arguments tab页中填写wsdl的名称或url
如:http://127.0.0.1/webservice/InsurWebService?wsdl
4.点击run 就可以在wsdl项目中生成我们需要的java文件了
如果没有MyEclipse可以通过命令行来生成相关的java文件
1.编写axis.bat设置临时环境变量,有些jar包需要单独下载
set CLASSPATH=.;C:/Program Files/Java/jdk1.5.0_07/lib/tools.jar;D:/axis-1_4/lib/axis-ant.jar;D:/axis-1_4/lib/axis.jar;D:/axis-1_4/lib/commons-discovery-0.2.jar;D:/axis-1_4/lib/commons-logging-1.0.4.jar;D:/axis-1_4/lib/jaxrpc.jar;D:/axis-1_4/lib/log4j-1.2.8.jar;D:/axis-1_4/lib/log4j.properties;D:/axis-1_4/lib/saaj.jar;D:/axis-1_4/lib/wsdl4j-1.5.1.jar;D:/axis-1_4/lib/activation.jar;D:/axis-1_4/lib/javax.servlet.jar;D:/axis-1_4/lib/javax.servlet.jsp.jar;D:/axis-1_4/lib/jboss-j2ee.jar;D:/axis-1_4/lib/jboss-jaxrpc.jar;D:/axis-1_4/lib/jboss-jsr77.jar;D:/axis-1_4/lib/jboss-saaj.jar;D:/axis-1_4/lib/mail.jar;D:/axis-1_4/lib/namespace.jar;D:/axis-1_4/lib/xml-apis.jar;
2.cmd进入命令行窗口
D:/axis-1_4>axis.bat
D:/axis-1_4>java org.apache.axis.wsdl.WSDL2Java http://127.0.0.1/webservice/InsurWebService?wsdl
运行 jar包中的WSDL2java中的main方法,生成客户端代码。
下面是wsdl2java的参数:
The wsdl URI was not specified.
Usage: java org.apache.axis.wsdl.WSDL2Java [options] WSDL-URI
Options:
-h, --help
print this message and exit
-v, --verbose
print informational messages
-n, --noImports
only generate code for the immediate WSDL document
-O, --timeout <argument>
timeout in seconds (default is 45, specify -1 to disable)
-D, --Debug
print debug information
-W, --noWrapped
turn off support for "wrapped" document/literal
-q, --quiet
do not print any informational or debug messages (except err
ors)
-s, --server-side
emit server-side bindings for web service
-S, --skeletonDeploy <argument>
deploy skeleton (true) or implementation (false) in deploy.w
sdd. Default is false. Assumes --server-side.
-N, --NStoPkg <argument>=<value>
mapping of namespace to package
-f, --fileNStoPkg <argument>
file of NStoPkg mappings (default NStoPkg.properties)
-p, --package <argument>
override all namespace to package mappings, use this package
name instead
-o, --output <argument>
output directory for emitted files
-d, --deployScope <argument>
add scope to deploy.wsdd: "Application", "Request", "Session
"
-t, --testCase
emit junit testcase class for web service
-a, --all
generate code for all elements, even unreferenced ones
-T, --typeMappingVersion <argument>
indicate 1.1 or 1.2. The default is 1.1 (SOAP 1.1 JAX-RPC c
ompliant. 1.2 indicates SOAP 1.1 encoded.)
-F, --factory <argument>
name of a custom class that implements GeneratorFactory inte
rface (for extending Java generation functions)
-H, --helperGen
emits separate Helper classes for meta data
-B, --buildFile
emit Ant Buildfile for web service
-U, --user <argument>
username to access the WSDL-URI
-P, --password <argument>
password to access the WSDL-URI
-X, --classpath
additional classpath elements
-i, --nsInclude <argument>
include namespace in generated code
-x, --nsExclude <argument>
exclude namespace from generated code
-c, --implementationClassName <argument>
custom name of web service implementation
-u, --allowInvalidURL
emit file even if WSDL endpoint URL is not a valid URL
-w, --wrapArrays
Prefers building beans to straight arrays for wrapped XML ar
ray types (defaults to off).

浙公网安备 33010602011771号