Вопрос

I'm creating xsd file for my service and want to generate classes from it. But idea highlights complexTypes and when generating classes - occurs [ERROR] underfined element declaration StepResponse. I looked examples here and here, but in my occasion it didn't work. Here is the code:

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://com/tictocsoa/ws" elementFormDefault="qualified">

    <element name="StepRequest" type="GameStep"/>
    <element name="StepResponse" type="GameStep"/>
    <element name="StepsResponse" type="GameSteps"/>

    <complexType name="GameStep">
        <sequence>
            <element name="gameId" type="int"/>
            <element name="num" type="int"/>
            <element name="cell" type="int"/>
        </sequence>
    </complexType>

    <complexType name="GameSteps">
        <sequence maxOccurs="unbounded" minOccurs="0">
            <element name="steps" type="GameStep"/>
        </sequence>
    </complexType>

</schema>

Why can't it find this type? I simply want to generate 2 classes: first for one Object and another for List of it (for getById and getAll methods respectively). Another question - maybe it woulde be e better create one class for both?

P.S. generating with jaxb-ri-2.2.7

Это было полезно?

Решение

You missed the perfix for your namespace, try something like that:

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
  targetNamespace="http://com/tictocsoa/ws" 
  elementFormDefault="qualified"
  xmlns:tts="http://com/tictocsoa/ws">

<element name="StepRequest" type="tts:GameStep"/>
<element name="StepResponse" type="tts:GameStep"/>
<element name="StepsResponse" type="tts:GameSteps"/>

<complexType name="GameStep">
    <sequence>
        <element name="gameId" type="int"/>
        <element name="num" type="int"/>
        <element name="cell" type="int"/>
    </sequence>
</complexType>

<complexType name="GameSteps">
    <sequence maxOccurs="unbounded" minOccurs="0">
        <element name="steps" type="tts:GameStep"/>
    </sequence>
</complexType>

</schema>
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top