First, the preparatory work (The following is an example using the tool)
1、MyEclipse10.7.1
2、JDK 1.6.0_22
Second, create a server
1. Create a Web Service Project [], [named] TheService.
2. Create a class [Class] named [ServiceHello], located at [com.hyan.service] package.
3. A method for the preparation of client calls, that is compiled method code.
4, compile
Description: Compilation failed, please reference the project is set to jdk version 1.6.0_17 or later
5, the test results
Test Address: HTTP: // localhost: 9001 / Service / wsdl the ServiceHello?
Third, generate client
1. Create a Web Service Project [], [named] TheClient.
2, the command prompt window, execute the command generation.
Format: wsimport -s "src directory" -p "where the generated class package name" -keep "wsdl publishing address"
Example:
wsimport -s G:\\workspace\\webService\\TheClient\\src -p com.hyan.client -keep http://localhost:9001/Service/ServiceHello?wsdl
Description:
1) "src directory" address can not contain spaces
2) "wsdl publishing address" do not leak "? Wsdl"
3, refresh the project, check the generated class
Fourth, the final test
1, create a class [Class] named [ServiceTest], [com.hyan.test] located under the package.
2, write a test method, the server calls the method, and print the results returned.
V. Notes
1, JDK version is too low problems
报类似如下的异常:runtime modeler error: Wrapper class com.hyan.service.jaxws.GetValue is not found. Have you run APT to generate them?
原因:JDK版本低于1.6.0_17
解决方法:调整该服务端项目所引用的JDK版本为安装的高版本JDK
2、生成命令路径含空格问题
报类似如下的异常:directory not found: G:\SVN_FILE\GB\05
原因:客户端src路径不可含有空格
解决方法:在不含空格路径的文件夹下重新创建客户端即可。
3、生成命令不完整问题
报类似如下的异常:[ERROR] failed.noservice=Could not find wsdl:service in the provided WSDL(s):
原因:生成命令末尾缺少“?wsdl”
解决方法:补上即可。
错误不完整的命令示例:
wsimport -s G:\\workspace\\webService\\TheClient\\src -p com.hyan.client -keep http://localhost:9001/Service/ServiceHello
正确完整的命令示例:
wsimport -s G:\\workspace\\webService\\TheClient\\src -p com.hyan.client -keep http://localhost:9001/Service/ServiceHello?wsdl
Six, example source code
Server source code download
Client source code download