2

I am using JAX-WS 2.1 to generate artifacts from xsd file for Web services.

Here the XSD definition of the problemtic artifact:

<xs:simpleType name='Example'>
    <xs:annotation>
      <xs:documentation>Example</xs:documentation>
    </xs:annotation>
    <xs:restriction base='xs:string'>
      <xs:minLength value='0'/>
      <xs:maxLength value='1'/>
    </xs:restriction>
</xs:simpleType>

Jax WS does not generate artifact Example. I do not see class with name Example.

But when I am adding enum to XSD definition then JAX-WS succes generate it:

<xs:simpleType name='Example'>
    <xs:annotation>
      <xs:documentation>Example</xs:documentation>
    </xs:annotation>
    <xs:restriction base='xs:string'>
      <xs:minLength value='0'/>
      <xs:maxLength value='1'/>
      <xs:enumeration value='A'/>
    </xs:restriction>
</xs:simpleType>

If somebody know what the problem please help

Benoit
  • 1,995
  • 1
  • 13
  • 18

2 Answers2

0

xs:minLength, xs:maxLength cann't be used with xs:enumeration. Enumeratio is collection of fixed values, xs:minLength, xs:maxLength requared for values that is entered in application. So use only enumeration

  <xsd:restriction base="xsd:string">
     <xsd:enumeration value="A"/>
     <xsd:enumeration value="B"/>
     <xsd:enumeration value="C"/>
  </xsd:restriction>
Ilya
  • 29,135
  • 19
  • 110
  • 158
  • Thanks for the answer.But why when I am using only xs:minLength, xs:maxLength then JAX WS does not generate artifact? In original, XSD come only with . I added enum to check if Jax Ws will generate artifact. – Alexander Shevchenko Aug 13 '12 at 07:56
0

To get a class for your scenario you need a custom binding. This post on SO shows you the structure of the custom binding file.

One of the things you need to keep in mind is that JAXB by default will generate a class for a complex type, and not for a simple type.

Community
  • 1
  • 1
Petru Gardea
  • 21,373
  • 2
  • 50
  • 62