Java – generated web service client class without setter

I have created a client for the soap web service, but in the generated code, some classes miss the setter method

The WSDL of the object is as follows:

<xsd:complexType name="UserDefinedFieldArray">
<xsd:sequence>
<xsd:element name="userDefinedField" minOccurs="0" maxOccurs="unbounded"  
           type="ns0:UserDefinedField"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="UserDefinedField">
<xsd:sequence>
<xsd:element name="fieldName" type="xsd:string"/>
<xsd:element name="fieldValue" type="xsd:string"/>
<xsd:element name="listId" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>

These objects only have setXXX (), and Java docs insists on this:

"This accessor method returns a reference to the real-time list instead of a snapshot. Therefore, any changes you make to the returned list will appear in the JAXB object. This is why the testsuiteudfs property has no set method. For example, to add a new item, do the following: gettestsuiteudfs(). Add (newitem)“

Although my logic tells me that the updated list cannot reach the server until you send it there?

The only relevant thing I managed to find: http://www-01.ibm.com/support/docview.wss?uid=swg21440294. But it's useless

Who can tell me which way to dig? Because I don't understand what's going on thank you!

Solution

Updating the JAXB mapped domain object does not result in communication with the server JAXB (JSR - 222) is a standard for converting objects to or from XML Jax-ws (soap) and jax-rs (restful) frameworks use it to generate / use messages sent between clients and servers over lines

UPDATE

All this means that the list you get is a real list, not a copy You can test it with the following code:

System.out.println(customer.getPhoneNumbers().size());  // returns x
customer.getPhoneNumbers().add(new PhoneNumber());
System.out.println(customer.getPhoneNumbers().size());  // returns x + 1
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>