我正在使用 Apache CXF 进行 Web 服务开发。我们写好了Java代码,WSDL会由CXF引擎自动生成
我有一个名为 xmlMessage 的 String
必须将 minoccurs
设置为 1
为此,我使用了:
private String xmlMessage ;
@XmlElement(name = "xmlMessage", required = true)
public String getXmlMessage()
{
return xmlMessage;
}
但是当生成 WSDL 文件时,它仍然显示为
<xs:element minOccurs="0" name="xmlMessage" type="xs:string"/>
请告诉我如何让 minOccurs="1"用于输入消息。
最佳答案
这似乎是一个错误。 sun api 定义了 required作为:
Customize the element declaration to be required.
If
required()
istrue
, then Javabean property is mapped to an XML schema element declaration withminOccurs="1"
.maxOccurs is "1"
for a single valued property and"unbounded"
for a multivalued property.If
required()
isfalse
, then the Javabean property is mapped to XML Schema element declaration withminOccurs="0"
.maxOccurs is "1"
for a single valued property and"unbounded"
for a multivalued property.Default: false
可能是 this bug ,不知道你的版本是不是新的。
关于java - 我们如何让一个字符串出现 minOccurs ="1"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9001908/