简体   繁体   English

生成的Web服务客户端类,没有setter

[英]Generated web services client classes with no setters

I've created a client for SOAP web service, but in the generated code some classes miss setter methods. 我已经为SOAP Web服务创建了一个客户端,但是在生成的代码中,一些类错过了setter方法。

WSDL for the objects looks like: 对象的WSDL如下所示:

<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>

Those objects have only setXXX(), and Java Docs insist on this: 这些对象只有setXXX(),Java Docs坚持这​​样:

"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 set method for the testSuiteUdfs property. For example, to add a new item, do as follows: getTestSuiteUdfs().add(newItem); " “此访问器方法返回对实时列表的引用,而不是快照。因此,您对返回列表所做的任何修改都将出现在JAXB对象中。这就是为什么testSuiteUdfs属性没有set方法。例如,要添加新项,请执行以下操作:getTestSuiteUdfs()。add(newItem);“

Though my logic says to me, that the updated list cannot get to the server until u send it there? 虽然我的逻辑告诉我,更新的列表无法到达服务器,直到你发送到那里?

The only related thing I managed to find: http://www-01.ibm.com/support/docview.wss?uid=swg21440294 . 我找到的唯一相关的事情是: http//www-01.ibm.com/support/docview.wss?uid = swg21440294 But it was not helpful at all. 但它根本没用。

Can anyone, please, tell me which way to dig? 请问有谁可以告诉我哪种方式可以挖掘? Cause I don't understand at all how this is supposed to work. 因为我根本不明白这是怎么回事。 Thanks! 谢谢!

Updating a domain object mapped by JAXB does not cause communication with the server. 更新JAXB映射的域对象不会导致与服务器的通信。 JAXB (JSR-222) is a standard for converting objects to/from XML. JAXB(JSR-222)是用于将对象转换为XML或从XML转换对象的标准。 It is leveraged by JAX-WS (SOAP) and JAX-RS (RESTful) frameworks to produce/consume messages sent over the wire between clients an servers. JAX-WS(SOAP)和JAX-RS(RESTful)框架利用它来生成/使用通过线路在客户端和服务器之间发送的消息。

UPDATE UPDATE

" any modification you make to the returned list will be present inside the JAXB object." “您对返回列表所做的任何修改都将出现在JAXB对象中。”

All this means is that the List you get is the real List and not a copy. 所有这些意味着你获得的List是真正的List而不是副本。 You can test this out 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

use @XmlElementWrapper on the element you want to expose as list or array type. 在要作为列表或数组类型公开的元素上使用@XmlElementWrapper。 Make sure you set name for @XmlElement, which the generated stub code in the client don't confuse the class names. 确保为@XmlElement设置名称,客户端中生成的存根代码不会混淆类名。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM