当前位置: 动力学知识库 > 问答 > 编程问答 >

java - How to control what fields are included in generated webservice types?

问题描述:

I am working on a legacy system, where webservice-clients were included as packaged .jar-files. We wanted to change this, to instead generate the clients. But after this was done, there were some differences, where the .jar-clients had access to all fields of the returned objects, there were some missing in the generated versions. (They were actually missing from the generated xsd of the service, and thus not generated in the client). We pretty quickly noticed that the difference between the missing fields, and the ones that were present was that the missing ones did not have both a getter and a setter. After adding these, most of the fields were included, but not the ones were the return type of the service-method was a List.

So my question is, which methods must be present in order for a field to be included in the xsd-schema of a service? And more specifically, which methods must be present for a collection to be included?

In the service-class:

public Organization getOrganization(final Integer id) {

return something.getOrganization(id);

}

and in Organization:

public class Organization {

private Integer id;

private List<String> phoneNumbers;

private String name;

public Organization(final String name) {

this.name = name;

}

public String getName() {

return name;

}

//No setter for name, so the field is not included in the wsdl..

public Integer getId() {

return id;

}

public void setId(final Integer id) {

this.id = id;

}

//Id has both setter and getter, so it is included..

public List<String> getPhoneNumbers() {

return phoneNumbers;

}

public void setPhoneNumbers(final List<String> phoneNumbers) {

this.phoneNumbers = phoneNumbers;

}

//phoneNumbers has both getter and setter, but still is not included.

//I guess it is because it is a list.

分享给朋友:
您可能感兴趣的文章:
随机阅读: