''}'';
}
}
Java6 WebService使用复杂对象(2)
时间:2011-02-07 51cto博客 leizhimin
package lavasoft.server;
/**
* Created by IntelliJ IDEA.
*
* @author leizhimin 2009-11-16 17:09:46
*/
public class Foo {
private String name;
private String sex;
public Foo() {
}
public Foo(String name, String sex) {
this.name = name;
this.sex = sex;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
@Override
public String toString() {
return "Foo{" +
"sex=''" + sex + ''\'''' +
", name=''" + name + ''\'''' +
''}'';
}
}
2、生成客户端代码
可以清楚的看出,在客户端代码中,已经生成了服务接口和服务实现类,还生成了UserBean和Foo两个类,而这两个类和服务端的内容不同。
Java6 WebService使用复杂对象(3)
时间:2011-02-07 51cto博客 leizhimin
3、写客户端测试代码
package lavasoft;
import lavasoft.wsclient.Foo;
import lavasoft.wsclient.Java6WS;
import lavasoft.wsclient.Java6WSService;
import lavasoft.wsclient.UserBean;
/**
* 测试Java6 WS生成的客户端代码
*
* @author leizhimin 2009-11-16 17:05:00
*/
public class TestClient {
public static void main(String[] args) {
//创建一个客户端服务对象
Java6WS java6WS = new Java6WSService().getJava6WSPort();
System.out.println("----------java6WS.doSomething1-------------");
//调用服务方法,并得到方法返回值
UserBean userBean = java6WS.doSomething1("zhangsan", "华中路", true);
//打印服务的返回值
System.out.println(userBean.toString());
System.out.println(userBean.getUsername() + " " + userBean.getAddress() + " " + userBean.isFlag());
System.out.println("----------java6WS.doSomething2-------------");
|