我正在使用CXF进行SOAP Web服务。是否存在生成的SOAP响应不符合WSDL的情况?我让CXF通过wsdl2java从WSDL生成代码。
例如,我有一些minOccurs=1
的实体。 CXF会强制相应的Java元素不会为空吗?
其他差异是否可能?
示例:我有以下WSDL类型:
<xsd:complexType name="PropertyList">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="1" name="property"
type="pms-xsd:Property" />
</xsd:sequence>
</xsd:complexType>
被翻译成:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "PropertyList", propOrder = {
"property"
})
public class PropertyList {
@XmlElement(required = true)
protected List<Property> property;
...
根据我的理解,这要求List property
存在(以XmlElement的形式),但不存在至少一个存在的属性,WSDL需要它。这是一个可能的问题,还是我理解错了?
答案 0 :(得分:0)
要强制执行架构,您需要启用架构验证。请检查here以启用架构验证。下面显示了示例代码段。
<jaxws:endpoint name="{http://apache.org/hello_world_soap_http}SoapPort"
wsdlLocation="wsdl/hello_world.wsdl"
createdFromAPI="true">
<jaxws:properties>
<entry key="schema-validation-enabled" value="true" />
</jaxws:properties>
</jaxws:endpoint>
注意:为了工作,您需要正确设置wsdl位置。这样在模式验证期间,WSDL文件被引用。