java - 我们如何让一个字符串出现 minOccurs ="1"?

标签 java wsdl jaxb cxf code-first

我正在使用 Apache CXF 进行 Web 服务开发。我们写好了Java代码,WSDL会由CXF引擎自动生成

我有一个名为 xmlMessageString 必须将 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() is true, then Javabean property is mapped to an XML schema element declaration with minOccurs="1". maxOccurs is "1" for a single valued property and "unbounded" for a multivalued property.

If required() is false, then the Javabean property is mapped to XML Schema element declaration with minOccurs="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/

相关文章:

JAVA/JAXB 需要帮助

java - 当前月份的开始和结束日期

java - ASM 中的类编写器 COMPUTE_FRAMES

java - mvn assembly :single and mvn compile assembly:single 和有什么区别

python - 为 Python Twisted SOAP 服务器自动生成 WSDL 文件

soap - CXF:入站策略验证失败:无法满足这些策略替代方案:

java - 为什么用ConfirmDialog关闭Frme窗口会在两种情况下(确定和取消)关闭?

java - 向特定服务发送 SOAP 请求

jaxb数组中的单个元素

java - 异常 : "Missing class indicator field from database row [UnmarshalRecordImpl()]." when unmarshalling XML using EclipseLink JAXB (MOXy)