有关于WebService接口返回Bean(非POJO)的重要问题

1 view
Skip to first unread message

Leroer

unread,
Jul 17, 2008, 10:25:38 PM7/17/08
to cxf-zh
现正做一个项目,采用CXF实现WebService。接口方法返回一个比较复杂的Bean,通过该Bean能获取到许多其他Bean/
POJO,因为考虑到性能问题,因此想把它做成延迟加载的方式,即在真正调用Bean的方法时,才去执行查询或其他操作。
例子代码:
=========================================================
package ws.cxf;
import javax.jws.WebService;

@WebService
public interface ClazzService {
public Clazz getClazz(Integer id);
}

---------------------------------------------------------------------------------------------------------------
package ws.cxf;
import java.io.Serializable;

public class Clazz implements Serializable {
private Integer id;
private String name;

public Integer getId(){return this.id;}
public void setId(Integer id){this.id=id;}
public String getName(){return this.name;}
public void setName(String name){this.name=name;}

public String getValue(){return new ValueUtil().getValue();}
}
在生成的WSDL文件里,没有vlaue属性,生成客户端访问程序时,bean里也没有getValue()这个方法
如果加上setValue()方法,就可以,而且在客户端访问时,也能正确获取到想要的值。
如果将getValue()改成loadValue(),则WSDL里也没有相关描述,客户端bean里也没有该方法。

大虾们,有没有什么解决方案?

willem

unread,
Jul 17, 2008, 11:19:49 PM7/17/08
to cxf-zh
拜托 LZ 有空还是研究一下JAXB, 没有了get, set 方法,如何设置你的属性。
还有为了传XML你的Clazz也不需要实现Serializable 接口。

姜宁 (Willem)
--------------------------------
http://willem.bokeland.com
http://www.ohloh.net/accounts/4473
Reply all
Reply to author
Forward
0 new messages