following xsd (partial):
<xs:complexType name="Fruit">
<xs:sequence>
<xs:element name="type" type="FruitType"/>
</xs:sequence>
</xs:complexType>
<xs:simpleType name="FruitType">
<xs:restriction base="xs:string">
<xs:enumeration value="ABC">
</xs:enumeration>
<xs:enumeration value="DEF">
</xs:enumeration>
<xs:enumeration value="GHI">
</xs:enumeration>
<xs:enumeration value="JKL">
</xs:enumeration>
</xs:restriction>
</xs:simpleType>
Generating code with xjc will generate the following java code (FruitType is an Enum):
@XmlElement(required = true)
@XmlSchemaType(name = "string")
protected FruitType fruit;
When generating a SOAP WebService with JAX-WS the following element will be generated:
<xs:element name="type" type="xs:string"/>
Which ist obviously wrong. I'd expect this to be
<xs:element name="type" type="FruitType"/>
If I delete this line by hand
@XmlSchemaType(name = "string")
in my Java Code everything in the wsdl is fine :
<xs:element name="type" type="tns:FruitType"/>
So the question is: How can I tell JAXB not to generate the @XmlSchemaType?
Instead of referencing FruitType with type
<xs:complexType name="Fruit">
<xs:sequence>
<xs:element name="type" type="FruitType"/>
</xs:sequence>
</xs:complexType>
the trick ist to have a simpleType inline:
<xs:complexType name="Fruit">
<xs:sequence>
<xs:element name="type">
<xs:simpleType>
<xs:restriction base="FruitType"/>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
this will generate the correct java file and WSDL:
<xs:element name="type" type="tns:FruitType"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With