我想在 Mule 3.4 社区中公开一个简单的 SOAP Web 服务。 服务的某些字段需要是强制性/必填的。怎么才能做到这一点?
这是网络服务方法:
public String methodname(String field1, String field2, String field3);
这是生成的 wsdl:
<xsd:element minOccurs="0" name="field1" nillable="true" type="xsd:string"/>
<xsd:element minOccurs="0" name="field2" nillable="true" type="xsd:string"/>
<xsd:element minOccurs="0" name="field3" nillable="true" type="xsd:string"/>
如何使这些字段 minOccurs="1"和 nillable="false"
请注意 @XmlElement(required=true) 不适用于我的 Java 版本 1.6
最佳答案
minOccurs="1"
使元素强制,minOccurs="0"
使其可选
因此,请进行以下更改以使其强制执行:-
<xsd:element minOccurs="1" name="field1" nillable="true" type="xsd:string"/>
<xsd:element minOccurs="1" name="field2" nillable="true" type="xsd:string"/>
<xsd:element minOccurs="1" name="field3" nillable="true" type="xsd:string"/>
和
How to tell if XML element is marked as required in the XSD file
和nillable
指定是否可以将显式空值分配给元素
引用:-http://www.w3schools.com/schema/el_element.asp
因此,您需要在 WSDL 中进行更改,以便从 生成的 Java 类实现属性的这些属性
关于java - MULE ESB 简单 SOAP 服务创建必填字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27748795/