Java6 WebService操纵复杂对象[Java编程]
本文“Java6 WebService操纵复杂对象[Java编程]”是由七道奇为您精心收集,来源于网络转载,文章版权归文章作者所有,本站不对其观点以及内容做任何评价,请读者自行判断,以下是其具体内容:
复杂对象可表示的语义比简单对象强盛很多,这里看看在Java6的WebService中若何利用复杂对象参数.
这里的参数分两类,一类是入参,一类是返回值.
复杂对象在并不像想象中那么简单,此中还有一些玄机.请看实例:
1、开辟服务,通通在服务端
package lavasoft.server;
import javax.jws.WebService;
import javax.xml.ws.Endpoint;
/**
* Java6开辟的WebService服务端
*
* @author leizhimin 2009-11-16 10:24:13
*/
@WebService
public class Java6WS {
//返回一个复杂对象
public UserBean doSomething1(String username, String address, boolean flag) {
return new UserBean(username, address, flag);
}
//接纳一个复杂对象
public String doSomething2(Foo foo) {
return foo.toString();
}
public static void main(String[] args) {
//公布一个WebService
Endpoint.publish("http://192.168.14.117:9999/java6ws/Java6WS", new Java6WS());
}
}
package lavasoft.server;
/**
* 用户信息
*
* @author leizhimin 2009-11-16 16:43:35
*/
public class UserBean {
private String username;
private String address;
private boolean flag;
public UserBean() {
}
public UserBean(String username, String address, boolean flag) {
this.username = username;
this.address = address;
this.flag = flag;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public boolean isFlag() {
return flag;
}
public void setFlag(boolean flag) {
this.flag = flag;
}
@Override
public String toString() {
return "UserBean{" +
"username='" + username + '\'' +
", address='" + address + '\'' +
", flag=" + flag +
'}';
}
}
以上是“Java6 WebService操纵复杂对象[Java编程]”的内容,如果你对以上该文章内容感兴趣,你可以看看七道奇为您推荐以下文章:
本文地址: | 与您的QQ/BBS好友分享! |