【发布时间】:2012-07-19 06:05:46
【问题描述】:
假设我有一个由使用 wsimport 的 jaxws soap 生成的客户端使用的 WCF 服务。 服务 SEI 看起来像
@WebMethod(operationName = "DoSomething", action = "http://mydomain.com/PersonService/Dosomething")
@WebResult(name = "DoSomethingResult", targetNamespace = "http://mydomain.com/")
@RequestWrapper(localName = "DoSomething", targetNamespace = "http://mydomain.com/", className = "webservice.jaxws.DoSomething")
@ResponseWrapper(localName = "DoSomethingResponse", targetNamespace = "http://mydomain.com/", className = "webservice.jaxws.DoSomething")
public Person doSomething(
@WebParam(name = "person", targetNamespace = "http://mydomain.com/")
Person person);
采用复杂类型 Person 并返回相同类型的 Person 并生成 DoSomething 看起来像
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"person"
})
@XmlRootElement(name = "DoSomething")
public class DoSomething {
@XmlElement(nillable = true)
protected Person person;
public Person getPerson() {
return person;
}
public void setPerson(Person value) {
this.person = value;
}
如果 Person 与 DoSomething 是同一个包,则一切正常,只要我将 Person 移到其他地方,WCF 服务就无法从 Person 对象中获取任何内容(字段为 null 或 0),WCF 的返回值无法正确反序列化由 JAXWS 提供,但也不例外。
我注意到如果它们在同一个包中,那么 setPerson 将被调用,但如果它们在不同的包中则不会。
我想知道是否可以将复杂类型 Person 放在与 DoSomething 不同的包中。
【问题讨论】:
标签: java wcf jax-ws jax-ws-customization