I have generated java client from a Wsdl. I am stuck at following code where I have to set some setters values in following List<JAXBElement<?>>
public class SampleVerificationDomain
extends BaseDomain
{
protected List<JAXBElement<?>> rest;
/**
* Gets the rest of the content model.
*
* <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 rest property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getRest().add(newItem);
* </pre>
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link JAXBElement }{@code <}{@link String }{@code >}
* {@link JAXBElement }{@code <}{@link String }{@code >}
* {@link JAXBElement }{@code <}{@link String }{@code >}
* {@link JAXBElement }{@code <}{@link String }{@code >}
* {@link JAXBElement }{@code <}{@link DummyVerification }{@code >}
* {@link JAXBElement }{@code <}{@link String }{@code >}
*
*/
public List<JAXBElement<?>> getRest() {
if (rest == null) {
rest = new ArrayList<JAXBElement<?>>();
}
return this.rest;
}
I know how to store values if it is List<Class>
or List<String>
etc,
but how can I store value in a JAXBElement
of type <?>
and then store it in a List ?
UPDATE:
With help of this [https://stackoverflow.com/a/19548424/9811170], I have found ObjectFacotry class, which contains create functions of the values that needs to be set.
JAXBElement<?> jasbElem = null;
jasbElem = objectFactory.createSampleVerificationDomainCNIC("2392923");
jasbElem = objectFactory.createSampleVerificationDomainMSISDN("xxxxxxx");
jasbElem = objectFactory.createSampleVerificationDomainMsg("some message");
jasbElem = objectFactory.createSampleVerificationDomainUserName("apiusername");
jasbElem = objectFactory.createSampleVerificationDomainPassword("testpass");
SampleTestVerificationDomain.getRest().add(jasbElem);
But the above code only sets the last value in the JAXBElement. Any help on how to store all the values in JAXBElement ?