带字符串长度限制的JAXB @XmlElement(生成的XSD简单类型)

RKA*_*RKA 11 xsd wsdl jaxb maxlength simpletype

@XmlElement带字符串长度限制的JAXB (生成的XSD简单类型)

我使用Java生成SOAP Web服务.因此,这是代码第一种方法

在Java中我有一个String字段,我希望其长度限制为50个字符.

@XmlRootElement
public class ContactTO {

  private String comment; 

  @XmlElement
  public void setComment(String comment) {
    this.comment = comment;
  }
}

public class ContactWebService implements ContactServiceIf {

  @Override
  public ContactTO createContact(@WebParam(name = "newContact") ContactTO newContact)
  ...
Run Code Online (Sandbox Code Playgroud)

HTTP://本地主机:12080 /服务/ WSDL的ContactService

显示:

<xs:complexType name="contactTO">
 <xs:sequence>
  <xs:element minOccurs="0" name="comment" type="xs:string" /> 
Run Code Online (Sandbox Code Playgroud)

如何将注释元素限制为50?

我想要这样的东西:

  <xs:simpleType name="LimitedString">
    <xs:restriction base="xs:string">
      <xs:maxLength value="50" />
    </xs:restriction>
  </xs:simpleType>
Run Code Online (Sandbox Code Playgroud)

或类似的东西:

<xs:simpleType name="fourCharAlphaString">
  <xs:restriction base="xs:string">
    <xs:pattern value="[a-zA-Z]{4}"/>
  </xs:restriction>
</xs:simpleType>  
Run Code Online (Sandbox Code Playgroud)

但我无法手动编辑wsdl中的内联(生成)xsd.

非常感谢你.

(注意:XSD:如何限制字符串类型属性中的字符数?)

(注:http://www.w3schools.com/schema/schema_facets.asp)

谢谢,Reto