我从 Wsdl 生成了 java 客户端。我被困在下面的代码中,我必须在下面设置一些设置器值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;
}
我知道如何存储值,如果是List<Class>
等List<String>
,但我怎样才能将值存储在 aJAXBElement
类型中<?>
,然后将其存储在 List 中?
更新:
在此 [ https://stackoverflow.com/a/19548424/9811170]的帮助下,我找到了 ObjectFacotry 类,其中包含需要设置的值的创建函数。
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);
但是上面的代码只设置了 JAXBElement 中的最后一个值。有关如何将所有值存储在 JAXBElement 中的任何帮助?