用Eclipse 和 axis1.4 结合来自动生成JAVA代码非常方便。
1. 下载 axis1.4 相关包,解压后取得其中lib 下的所有JAR包,并导入ECLIPSE工程中。
2. 取得服务端提供的 wsdl 描述文件。
3. 在工程中运行 axis 包中的 wsdl2java :
org.apache.axis.wsdl.WSDL2Java
并设置参数
-u F:/MemberManagerFacade.wsdl(可以直接用URL,或者工程内部的相对路径 -u src/wsdl/MemberManagerFacade.wsdl)
-o src/main/java 指定输出的java类目录
-w 生成数组,默认为false
-S true 需要指定一个参数,若为true则会生成客户端骨架代码,若false则用实现的方式生成客户端代码。
4. 运行后自动生成 JAVA代码。
生成的JAVA代码中,除了BEAN外,会有2个接口,3个类
其中 Locator 类中继承了 org.apache.axis.client.Service
创建一个Locator 类就可以获取到调用接口,比如我的代码是这样的:
1.MemberManageFacadeLocator svc = new MemberManageFacadeLocator();
2.
3.MemberManageFacadePortType stub = svc.getMemberManageFacadeHttpPort();
4.//调用
5.String locationId = stub.queryXXXXNo("xxx", "xxxxx");
1.Usage: java org.apache.axis.wsdl.WSDL2Java [options] WSDL-URI
2.Options:
3. -h, --help
4. print this message and exit
5. -v, --verbose
6. print informational messages
7. -n, --noImports
8. only generate code for the immediate WSDL document
9. -O, --timeout <argument>
10. timeout in seconds (default is 45, specify -1 to disable)
11. -D, --Debug
12. print debug information
13. -W, --noWrapped
14. turn off support for "wrapped" document/literal
15. -q, --quiet
16. do not print any informational or debug messages (except errors)
17. -s, --server-side
18. emit server-side bindings for web service
19. -S, --skeletonDeploy <argument>
20. deploy skeleton (true) or implementation (false) in deploy.wsdd. Default is false. Assumes --server-side.
21. -N, --NStoPkg <argument>=<value>
22. mapping of namespace to package
23. -f, --fileNStoPkg <argument>
24. file of NStoPkg mappings (default NStoPkg.properties)
25. -p, --package <argument>
26. override all namespace to package mappings, use this packagename instead
27. -o, --output <argument>
28. output directory for emitted files
29. -d, --deployScope <argument>
30. add scope to deploy.wsdd: "Application", "Request", "Session"
31. -t, --testCase
32. emit junit testcase class for web service
33. -a, --all
34. generate code for all elements, even unreferenced ones
35. -T, --typeMappingVersion <argument>
36. indicate 1.1 or 1.2. The default is 1.1 (SOAP 1.1 JAX-RPC compliant. 1.2 indicates SOAP 1.1 encoded.)
37. -F, --factory <argument>
38. name of a custom class that implements GeneratorFactory interface (for extending Java generation functions)
39. -H, --helperGen
40. emits separate Helper classes for meta data
41. -B, --buildFile
42. emit Ant Buildfile for web service
43. -U, --user <argument>
44. username to access the WSDL-URI
45. -P, --password <argument>
46. password to access the WSDL-URI
47. -X, --classpath
48. additional classpath elements
49. -i, --nsInclude <argument>
50. include namespace in generated code
51. -x, --nsExclude <argument>
52. exclude namespace from generated code
53. -c, --implementationClassName <argument>
54. custom name of web service implementation
55. -u, --allowInvalidURL
56. emit file even if WSDL endpoint URL is not a valid URL
57. -w, --wrapArrays
58. Prefers building beans to straight arrays for wrapped XML array types (defaults to off).
【转载地址】
http://desert3.iteye.com/blog/1464196
http://blog.csdn.net/jiangxueqin123/article/details/7006121