根据 this article about backwards compatibility in SOAP by IBM,他们声明在不违反契约(Contract)的情况下不能将新字段添加到输出类型。页面中的相关片段来自标题为现有数据类型中的新可选字段的部分...
You can add an element to an existing complexType as long as you make it optional (using the minOccurs="0" attribute). But be careful. Adding an optional element is a minor change only if its enclosing complexType is received as input to the new service. The new service cannot return a complexType with new fields. If an old client were to receive the new field, the client deserialization would fail because the client would not know about the new field.
这是 2004 年为 WSDL 1.1 规范编写的。在当前的 WSDL 1.2 规范下,这仍然是真的吗?有没有办法为新的未知字段定义“忽略”的默认行为?该声明似乎也特定于实现还是符合规范?
我正在努力解决演化返回复杂业务对象的 SOAP 服务的问题。随着消费者为他们找到用例,将添加新字段。我想避免为了简单地添加新字段而保留 N 个版本的服务。
最佳答案
从我个人的经验来看,情况仍然如此。我认为您主要关心的是版本控制方法。你可以看看: http://www.ibm.com/developerworks/webservices/library/ws-version/ ,或者离家更近的 Web Services API Versioning 。
关于soap - 在 SOAP 中向现有输出数据类型添加新字段的变通方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14988786/