If we generate classes using the wsdl2java tool then some of the classes do not generate the setter method since the get method will act as the setter method. Few of the calling applications need the setter method.
Below is an example of how to write the setter method for the classes generated by the wsdl2java tool.
e.g. Let's consider the example of the AddressList calls which contains the object of the Address class.
public class Address {
protected String addressLine1;
protected String addressLine2;
protected String cityName;
protected String stateName;
protected String countryCode;
protected String countryName;
protected String zipcode;
/**
* Gets the value of the addressLine1 property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getAddressLine1() {
return addressLine1;
}
/**
* Sets the value of the addressLine1 property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setAddressLine1(String value) {
this.addressLine1 = value;
}
/**
* Gets the value of the addressLine2 property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getAddressLine2() {
return addressLine2;
}
/**
* Sets the value of the addressLine2 property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setAddressLine2(String value) {
this.addressLine2 = value;
}
/**
* Gets the value of the cityName property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getCityName() {
return cityName;
}
/**
* Sets the value of the cityName property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setCityName(String value) {
this.cityName = value;
}
/**
* Gets the value of the stateName property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getStateName() {
return stateName;
}
/**
* Sets the value of the stateName property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setStateName(String value) {
this.stateName = value;
}
/**
* Gets the value of the countryCode property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getCountryCode() {
return countryCode;
}
/**
* Sets the value of the countryCode property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setCountryCode(String value) {
this.countryCode = value;
}
/**
* Gets the value of the countryName property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getCountryName() {
return countryName;
}
/**
* Sets the value of the countryName property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setCountryName(String value) {
this.countryName = value;
}
/**
* Gets the value of the zipcode property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getZipcode() {
return zipcode;
}
/**
* Sets the value of the zipcode property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setZipcode(String value) {
this.zipcode = value;
}
}
Below is example for writing setter method -
public class AddressList {
protected List<Address> address;
/**
* Gets the value of the address property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the address property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getAddress().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link Address }
*
*
*/
public List<Address> getAddress() {
if (address == null) {
address = new ArrayList<Address>();
}
return this.address;
}
public void setAddress(Address oaddress) {
if (null != address)
address.add(oaddress);
else {
List<Address> listAddress = new ArrayList<Address>();
listAddress.add(oaddress);
this.address = listAddress;
}
}
No comments:
Post a Comment
Please do not enter any spam link in the comment box.