环境:NetBeans 7.1.2 glassfish 3.1.2
我编写了一个 Web 服务,其方法返回 pojos。但是,当我在 IDE 中创建 WebService 引用(或使用 wsimport 手动创建)时,为 pojos 生成的类是空的。以下非常简单的 Web 服务演示了该问题。
网络服务类
package snhd.dx;
import javax.jws.WebMethod;
import javax.jws.WebService;
@WebService
public class ReturnPojo {
@WebMethod
public Pojo getPojo() {
return new Pojo();
}
}
它返回的 pojo
package snhd.dx;
public class Pojo {
public final static int iPojo = 1;
public String getText() {
return "POJO";
}
}
当我创建 Web 服务引用时,生成的类得到以下信息:
package snhd.dx;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for pojo complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="pojo">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "pojo")
public class Pojo {
}
我需要做什么才能使生成的 Pojo 版本包含正确的信息?