2

I am using cfx wsdl2java to generate the server (java files). I'm having troubles with one java class. This java class is a complexType and looks like:

EDIT#1: As sugested by @matejko219

<xsd:complexType name="TService">
    <xsd:sequence>
        <xsd:element name="id"
            type="xsd:int" />
        <xsd:element name="st"
            type="xsd:int" />
        <xsd:element name="loc"
            type="tns:TLoc" />
        <xsd:element minOccurs="0" name="str"
            type="xsd:string" />
        <xsd:element name="ti"
            type="xsd:int" />
        <xsd:element name="nump"
            type="xsd:int" />
        <xsd:element name="prc"
            type="xsd:int" />
        <xsd:element minOccurs="0" name="dcrt"
            type="xsd:dateTime" />
        <xsd:element minOccurs="0" name="dini"
            type="xsd:dateTime" />
        <xsd:element minOccurs="0" name="dend"
            type="xsd:dateTime" />
        <xsd:element name="ct"
            type="xsd:int" />
        <xsd:element minOccurs="0" name="ins"
            type="tns:TServiceInspections" />
        <xsd:element name="id"
            type="xsd:int" />
        <xsd:element name="st"
            type="xsd:int" />
        <xsd:element name="loc"
            type="tns:TLoc" />
        <xsd:element minOccurs="0" name="str"
            type="xsd:string" />
        <xsd:element name="ti"
            type="xsd:int" />
        <xsd:element name="nump"
            type="xsd:int" />
        <xsd:element name="prc"
            type="xsd:int" />
        <xsd:element minOccurs="0" name="dcrt"
            type="xsd:dateTime" />
        <xsd:element minOccurs="0" name="dini"
            type="xsd:dateTime" />
        <xsd:element minOccurs="0" name="dend"
            type="xsd:dateTime" />
        <xsd:element name="ct"
            type="xsd:int" />
        <xsd:element minOccurs="0" name="ins"
            type="tns:TServiceInspections" />
        <xsd:element name="area"
            type="xsd:int" />
        <xsd:element minOccurs="0" name="desc"
            type="xsd:string" />
        <xsd:element minOccurs="0" name="tsins"
            type="tns:TInspectionServices" />
        <xsd:element name="nc"
            type="xsd:boolean" />
        <xsd:element name="order"
            type="xsd:int" />
        <xsd:element minOccurs="0" name="tasks"
            type="tns:TServiceTasks"/>
    </xsd:sequence>
</xsd:complexType>

The generated java file TService.java has the variables as ArrayOf instead of just the types, for example in id.

 /**
         * Gets array of all "id" elements
         */
    int[] getIdArray();

    /**
     * Gets ith "id" element
     */
    int getIdArray(int i);

    /**
     * Gets (as xml) array of all "id" elements
     */
    org.apache.xmlbeans.XmlInt[] xgetIdArray();

    /**
     * Gets (as xml) ith "id" element
     */
    org.apache.xmlbeans.XmlInt xgetIdArray(int i);

    /**
     * Returns number of "id" element
     */
    int sizeOfIdArray();

    /**
     * Sets array of all "id" element
     */
    void setIdArray(int[] idArray);

    /**
     * Sets ith "id" element
     */
    void setIdArray(int i, int id);

    /**
     * Sets (as xml) array of all "id" element
     */
    void xsetIdArray(org.apache.xmlbeans.XmlInt[] idArray);

    /**
     * Sets (as xml) ith "id" element
     */
    void xsetIdArray(int i, org.apache.xmlbeans.XmlInt id);

    /**
     * Inserts the value as the ith "id" element
     */
    void insertId(int i, int id);

    /**
     * Appends the value as the last "id" element
     */
    void addId(int id);

    /**
     * Inserts and returns a new empty value (as xml) as the ith "id" element
     */
    org.apache.xmlbeans.XmlInt insertNewId(int i);

    /**
     * Appends and returns a new empty value (as xml) as the last "id" element
     */
    org.apache.xmlbeans.XmlInt addNewId();

    /**
     * Removes the ith "id" element
     */
    void removeId(int i);

Is something wrong with my wsdl file?

Thank you in advance!!

Eric
  • 1,108
  • 3
  • 11
  • 25
  • 1
    I think you don't have to specify maxOccurs attribute. Default value of minOccurs and maxOccurs is 1. Only if you want to make optional element you should set minOccurs to 0. – matejko219 Feb 23 '18 at 08:51
  • I deleted this attributes, just keeping this ones who are set to 0. But still happens the same.. Thank you anyways – Eric Feb 23 '18 at 08:59

1 Answers1

0

Some attributes were repeated, so wsdl2java read it as an array. The correct wsdl is:

<xsd:complexType name="TService">
    <xsd:sequence>
        <xsd:element name="id"
            type="xsd:int" />
        <xsd:element name="st"
            type="xsd:int" />
        <xsd:element name="loc"
            type="tns:TLoc" />
        <xsd:element minOccurs="0" name="str"
            type="xsd:string" />
        <xsd:element name="ti"
            type="xsd:int" />
        <xsd:element name="nump"
            type="xsd:int" />
        <xsd:element name="prc"
            type="xsd:int" />
        <xsd:element minOccurs="0" name="dcrt"
            type="xsd:dateTime" />
        <xsd:element minOccurs="0" name="dini"
            type="xsd:dateTime" />
        <xsd:element minOccurs="0" name="dend"
            type="xsd:dateTime" />
        <xsd:element name="ct"
            type="xsd:int" />
        <xsd:element minOccurs="0" name="ins"
            type="tns:TServiceInspections" />
        <xsd:element name="area"
            type="xsd:int" />
        <xsd:element minOccurs="0" name="desc"
            type="xsd:string" />
        <xsd:element minOccurs="0" name="tsins"
            type="tns:TInspectionServices" />
        <xsd:element name="nc"
            type="xsd:boolean" />
        <xsd:element name="order"
            type="xsd:int" />
        <xsd:element minOccurs="0" name="tasks"
            type="tns:TServiceTasks"/>
    </xsd:sequence>
</xsd:complexType>
Eric
  • 1,108
  • 3
  • 11
  • 25