Quantcast

Returning a JaxB Object from a Web Service Generates a Nested Class on the Client

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Returning a JaxB Object from a Web Service Generates a Nested Class on the Client

sselvia

When returning an object that is already annotated with JaxB annotations the generated Client classes using wsimport via Netbeans has the objects nested within the root element class.  If the JaxB annotations do not exist for the returned object the resulting object and objects contained inside are not nested together.  What are the necessary switches to get wsimport to not generate the nested classes?

 

Client Generated code of a JaxB returned Object:

 

package test;

 

import javax.xml.bind.annotation.XmlAccessType;

import javax.xml.bind.annotation.XmlAccessorType;

import javax.xml.bind.annotation.XmlAttribute;

import javax.xml.bind.annotation.XmlElement;

import javax.xml.bind.annotation.XmlRootElement;

import javax.xml.bind.annotation.XmlType;

import javax.xml.bind.annotation.XmlValue;

 

 

/**

* <p>Java class for anonymous complex type.

*

 * <p>The following schema fragment specifies the expected content contained within this class.

*

 * <pre>

* &lt;complexType>

*   &lt;complexContent>

*     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">

*       &lt;sequence>

*         &lt;element name="Narrative">

*           &lt;complexType>

*             &lt;simpleContent>

*               &lt;extension base="&lt;http://www.w3.org/2001/XMLSchema>string">

*                 &lt;attribute name="Modified" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />

*                 &lt;attribute name="UserID" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />

*               &lt;/extension>

*             &lt;/simpleContent>

*           &lt;/complexType>

*         &lt;/element>

*       &lt;/sequence>

*       &lt;attribute name="DataFuse" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />

*       &lt;attribute name="Version" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />

*       &lt;attribute name="Validation" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />

*       &lt;attribute name="Code" type="{http://www.w3.org/2001/XMLSchema}int" />

*       &lt;attribute name="Message" type="{http://www.w3.org/2001/XMLSchema}string" />

*     &lt;/restriction>

*   &lt;/complexContent>

* &lt;/complexType>

* </pre>

*

 *

 */

@XmlAccessorType(XmlAccessType.FIELD)

@XmlType(name = "", propOrder = {

    "narrative"

})

@XmlRootElement(name = "WorkFlowSettings")

public class WorkFlowSettings {

 

    @XmlElement(name = "Narrative", required = true)

    protected WorkFlowSettings.Narrative narrative;

    @XmlAttribute(name = "DataFuse", required = true)

    protected String dataFuse;

    @XmlAttribute(name = "Version", required = true)

    protected String version;

    @XmlAttribute(name = "Validation", required = true)

    protected String validation;

    @XmlAttribute(name = "Code")

    protected Integer code;

    @XmlAttribute(name = "Message")

    protected String message;

 

    /**

     * Gets the value of the narrative property.

     *

     * @return

     *     possible object is

     *     {@link WorkFlowSettings.Narrative }

     *    

     */

    public WorkFlowSettings.Narrative getNarrative() {

        return narrative;

    }

 

    /**

     * Sets the value of the narrative property.

     *

     * @param value

     *     allowed object is

     *     {@link WorkFlowSettings.Narrative }

     *    

     */

    public void setNarrative(WorkFlowSettings.Narrative value) {

        this.narrative = value;

    }

 

    /**

     * Gets the value of the dataFuse property.

     *

     * @return

     *     possible object is

     *     {@link String }

     *    

     */

    public String getDataFuse() {

        return dataFuse;

    }

 

    /**

     * Sets the value of the dataFuse property.

     *

     * @param value

     *     allowed object is

     *     {@link String }

     *    

     */

    public void setDataFuse(String value) {

        this.dataFuse = value;

    }

 

    /**

     * Gets the value of the version property.

     *

     * @return

     *     possible object is

     *     {@link String }

     *    

     */

    public String getVersion() {

        return version;

    }

 

    /**

     * Sets the value of the version property.

     *

     * @param value

     *     allowed object is

     *     {@link String }

     *    

     */

    public void setVersion(String value) {

        this.version = value;

    }

 

    /**

     * Gets the value of the validation property.

     *

     * @return

     *     possible object is

     *     {@link String }

     *    

     */

    public String getValidation() {

        return validation;

    }

 

    /**

     * Sets the value of the validation property.

     *

     * @param value

     *     allowed object is

     *     {@link String }

     *    

     */

    public void setValidation(String value) {

        this.validation = value;

    }

 

    /**

     * Gets the value of the code property.

     *

     * @return

     *     possible object is

     *     {@link Integer }

     *    

     */

    public Integer getCode() {

        return code;

    }

 

    /**

     * Sets the value of the code property.

     *

     * @param value

     *     allowed object is

     *     {@link Integer }

     *    

     */

    public void setCode(Integer value) {

        this.code = value;

    }

 

    /**

     * Gets the value of the message property.

     *

     * @return

     *     possible object is

     *     {@link String }

     *    

     */

    public String getMessage() {

        return message;

    }

 

    /**

     * Sets the value of the message property.

     *

     * @param value

     *     allowed object is

     *     {@link String }

     *    

     */

    public void setMessage(String value) {

        this.message = value;

    }

 

 

    /**

     * <p>Java class for anonymous complex type.

     *

     * <p>The following schema fragment specifies the expected content contained within this class.

     *

     * <pre>

     * &lt;complexType>

     *   &lt;simpleContent>

     *     &lt;extension base="&lt;http://www.w3.org/2001/XMLSchema>string">

     *       &lt;attribute name="Modified" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />

     *       &lt;attribute name="UserID" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />

     *     &lt;/extension>

     *   &lt;/simpleContent>

     * &lt;/complexType>

     * </pre>

     *

     *

     */

    @XmlAccessorType(XmlAccessType.FIELD)

    @XmlType(name = "", propOrder = {

        "value"

    })

    public static class Narrative {

 

        @XmlValue

        protected String value;

        @XmlAttribute(name = "Modified", required = true)

        protected String modified;

        @XmlAttribute(name = "UserID", required = true)

        protected String userID;

 

        /**

         * Gets the value of the value property.

         *

         * @return

         *     possible object is

         *     {@link String }

         *    

         */

        public String getValue() {

            return value;

        }

 

        /**

         * Sets the value of the value property.

         *

         * @param value

         *     allowed object is

         *     {@link String }

         *    

         */

        public void setValue(String value) {

            this.value = value;

        }

 

        /**

         * Gets the value of the modified property.

         *

         * @return

         *     possible object is

         *     {@link String }

         *    

         */

        public String getModified() {

            return modified;

        }

 

        /**

         * Sets the value of the modified property.

         *

         * @param value

         *     allowed object is

         *     {@link String }

         *    

         */

        public void setModified(String value) {

            this.modified = value;

        }

 

        /**

         * Gets the value of the userID property.

         *

         * @return

         *     possible object is

         *     {@link String }

         *    

         */

        public String getUserID() {

            return userID;

        }

 

        /**

         * Sets the value of the userID property.

         *

         * @param value

         *     allowed object is

         *     {@link String }

         *    

         */

        public void setUserID(String value) {

            this.userID = value;

        }

 

    }

 

}

 

Client Generated code from a non-JaxB Object:

 

 

package test;

 

import javax.xml.bind.annotation.XmlAccessType;

import javax.xml.bind.annotation.XmlAccessorType;

import javax.xml.bind.annotation.XmlType;

 

 

/**

* <p>Java class for noJaxBWorkFlowSettings complex type.

*

 * <p>The following schema fragment specifies the expected content contained within this class.

*

 * <pre>

* &lt;complexType name="noJaxBWorkFlowSettings">

*   &lt;complexContent>

*     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">

*       &lt;sequence>

*         &lt;element name="code" type="{http://www.w3.org/2001/XMLSchema}int" minOccurs="0"/>

*         &lt;element name="dataFuse" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>

*         &lt;element name="message" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>

*         &lt;element name="narrative" type="{http://test/}noJaxBNarrative" minOccurs="0"/>

*         &lt;element name="validation" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>

*         &lt;element name="version" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>

*       &lt;/sequence>

*     &lt;/restriction>

*   &lt;/complexContent>

* &lt;/complexType>

* </pre>

*

 *

 */

@XmlAccessorType(XmlAccessType.FIELD)

@XmlType(name = "noJaxBWorkFlowSettings", propOrder = {

    "code",

    "dataFuse",

    "message",

    "narrative",

    "validation",

    "version"

})

public class NoJaxBWorkFlowSettings {

 

    protected Integer code;

    protected String dataFuse;

    protected String message;

    protected NoJaxBNarrative narrative;

    protected String validation;

    protected String version;

 

    /**

     * Gets the value of the code property.

     *

     * @return

     *     possible object is

     *     {@link Integer }

     *    

     */

    public Integer getCode() {

        return code;

    }

 

    /**

     * Sets the value of the code property.

     *

     * @param value

     *     allowed object is

     *     {@link Integer }

     *    

     */

    public void setCode(Integer value) {

        this.code = value;

    }

 

    /**

     * Gets the value of the dataFuse property.

     *

     * @return

     *     possible object is

     *     {@link String }

     *    

     */

    public String getDataFuse() {

        return dataFuse;

    }

 

    /**

     * Sets the value of the dataFuse property.

     *

     * @param value

     *     allowed object is

     *     {@link String }

     *    

     */

    public void setDataFuse(String value) {

        this.dataFuse = value;

    }

 

    /**

     * Gets the value of the message property.

     *

     * @return

     *     possible object is

     *     {@link String }

     *    

     */

    public String getMessage() {

        return message;

    }

 

    /**

     * Sets the value of the message property.

     *

     * @param value

     *     allowed object is

     *     {@link String }

     *    

     */

    public void setMessage(String value) {

        this.message = value;

    }

 

    /**

     * Gets the value of the narrative property.

     *

     * @return

     *     possible object is

     *     {@link NoJaxBNarrative }

     *    

     */

    public NoJaxBNarrative getNarrative() {

        return narrative;

    }

 

    /**

     * Sets the value of the narrative property.

     *

     * @param value

     *     allowed object is

     *     {@link NoJaxBNarrative }

     *    

     */

   public void setNarrative(NoJaxBNarrative value) {

        this.narrative = value;

    }

 

    /**

     * Gets the value of the validation property.

     *

     * @return

     *     possible object is

     *     {@link String }

     *    

     */

    public String getValidation() {

        return validation;

    }

 

    /**

     * Sets the value of the validation property.

     *

     * @param value

     *     allowed object is

     *     {@link String }

     *    

     */

    public void setValidation(String value) {

        this.validation = value;

    }

 

    /**

     * Gets the value of the version property.

     *

     * @return

     *     possible object is

     *     {@link String }

     *    

     */

    public String getVersion() {

        return version;

    }

 

    /**

     * Sets the value of the version property.

     *

     * @param value

     *     allowed object is

     *     {@link String }

     *    

     */

    public void setVersion(String value) {

        this.version = value;

    }

 

}

 

 

package test;

 

import javax.xml.bind.annotation.XmlAccessType;

import javax.xml.bind.annotation.XmlAccessorType;

import javax.xml.bind.annotation.XmlType;

 

 

/**

* <p>Java class for noJaxBNarrative complex type.

*

 * <p>The following schema fragment specifies the expected content contained within this class.

*

 * <pre>

* &lt;complexType name="noJaxBNarrative">

*   &lt;complexContent>

*     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">

*       &lt;sequence>

*         &lt;element name="modified" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>

*         &lt;element name="userID" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>

*         &lt;element name="value" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>

*       &lt;/sequence>

*     &lt;/restriction>

*   &lt;/complexContent>

* &lt;/complexType>

* </pre>

*

 *

 */

@XmlAccessorType(XmlAccessType.FIELD)

@XmlType(name = "noJaxBNarrative", propOrder = {

    "modified",

    "userID",

    "value"

})

public class NoJaxBNarrative {

 

    protected String modified;

    protected String userID;

    protected String value;

 

    /**

     * Gets the value of the modified property.

     *

     * @return

     *     possible object is

     *     {@link String }

     *    

     */

    public String getModified() {

        return modified;

    }

 

    /**

     * Sets the value of the modified property.

     *

     * @param value

     *     allowed object is

     *     {@link String }

     *    

     */

    public void setModified(String value) {

        this.modified = value;

    }

 

    /**

     * Gets the value of the userID property.

     *

     * @return

    *     possible object is

     *     {@link String }

     *    

     */

    public String getUserID() {

        return userID;

    }

 

    /**

     * Sets the value of the userID property.

     *

     * @param value

     *     allowed object is

     *     {@link String }

     *    

     */

    public void setUserID(String value) {

        this.userID = value;

    }

 

    /**

     * Gets the value of the value property.

     *

     * @return

     *     possible object is

     *     {@link String }

     *    

     */

    public String getValue() {

        return value;

    }

 

    /**

     * Sets the value of the value property.

     *

     * @param value

     *     allowed object is

     *     {@link String }

     *    

     */

    public void setValue(String value) {

        this.value = value;

    }

 

}

Scott Selvia
(O) 813.960.7800 x102
(F) 813.960.7811
http://www.datamentors.com

email_dm_logo

 

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Returning a JaxB Object from a Web Service Generates a Nested Class on the Client

Stefan Magnus Landrø
More details, please.

Could you please provide the WSDL and the command you use?
Also - I would recommend generating stubs using maven, gradle or ant or whatever instead of doing this in netbeans.

Stefan


2015-08-17 21:49 GMT+02:00 Scott Selvia <[hidden email]>:

When returning an object that is already annotated with JaxB annotations the generated Client classes using wsimport via Netbeans has the objects nested within the root element class.  If the JaxB annotations do not exist for the returned object the resulting object and objects contained inside are not nested together.  What are the necessary switches to get wsimport to not generate the nested classes?

 

Client Generated code of a JaxB returned Object:

 

package test;

 

import javax.xml.bind.annotation.XmlAccessType;

import javax.xml.bind.annotation.XmlAccessorType;

import javax.xml.bind.annotation.XmlAttribute;

import javax.xml.bind.annotation.XmlElement;

import javax.xml.bind.annotation.XmlRootElement;

import javax.xml.bind.annotation.XmlType;

import javax.xml.bind.annotation.XmlValue;

 

 

/**

* <p>Java class for anonymous complex type.

*

 * <p>The following schema fragment specifies the expected content contained within this class.

*

 * <pre>

* &lt;complexType>

*   &lt;complexContent>

*     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">

*       &lt;sequence>

*         &lt;element name="Narrative">

*           &lt;complexType>

*             &lt;simpleContent>

*               &lt;extension base="&lt;http://www.w3.org/2001/XMLSchema>string">

*                 &lt;attribute name="Modified" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />

*                 &lt;attribute name="UserID" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />

*               &lt;/extension>

*             &lt;/simpleContent>

*           &lt;/complexType>

*         &lt;/element>

*       &lt;/sequence>

*       &lt;attribute name="DataFuse" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />

*       &lt;attribute name="Version" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />

*       &lt;attribute name="Validation" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />

*       &lt;attribute name="Code" type="{http://www.w3.org/2001/XMLSchema}int" />

*       &lt;attribute name="Message" type="{http://www.w3.org/2001/XMLSchema}string" />

*     &lt;/restriction>

*   &lt;/complexContent>

* &lt;/complexType>

* </pre>

*

 *

 */

@XmlAccessorType(XmlAccessType.FIELD)

@XmlType(name = "", propOrder = {

    "narrative"

})

@XmlRootElement(name = "WorkFlowSettings")

public class WorkFlowSettings {

 

    @XmlElement(name = "Narrative", required = true)

    protected WorkFlowSettings.Narrative narrative;

    @XmlAttribute(name = "DataFuse", required = true)

    protected String dataFuse;

    @XmlAttribute(name = "Version", required = true)

    protected String version;

    @XmlAttribute(name = "Validation", required = true)

    protected String validation;

    @XmlAttribute(name = "Code")

    protected Integer code;

    @XmlAttribute(name = "Message")

    protected String message;

 

    /**

     * Gets the value of the narrative property.

     *

     * @return

     *     possible object is

     *     {@link WorkFlowSettings.Narrative }

     *    

     */

    public WorkFlowSettings.Narrative getNarrative() {

        return narrative;

    }

 

    /**

     * Sets the value of the narrative property.

     *

     * @param value

     *     allowed object is

     *     {@link WorkFlowSettings.Narrative }

     *    

     */

    public void setNarrative(WorkFlowSettings.Narrative value) {

        this.narrative = value;

    }

 

    /**

     * Gets the value of the dataFuse property.

     *

     * @return

     *     possible object is

     *     {@link String }

     *    

     */

    public String getDataFuse() {

        return dataFuse;

    }

 

    /**

     * Sets the value of the dataFuse property.

     *

     * @param value

     *     allowed object is

     *     {@link String }

     *    

     */

    public void setDataFuse(String value) {

        this.dataFuse = value;

    }

 

    /**

     * Gets the value of the version property.

     *

     * @return

     *     possible object is

     *     {@link String }

     *    

     */

    public String getVersion() {

        return version;

    }

 

    /**

     * Sets the value of the version property.

     *

     * @param value

     *     allowed object is

     *     {@link String }

     *    

     */

    public void setVersion(String value) {

        this.version = value;

    }

 

    /**

     * Gets the value of the validation property.

     *

     * @return

     *     possible object is

     *     {@link String }

     *    

     */

    public String getValidation() {

        return validation;

    }

 

    /**

     * Sets the value of the validation property.

     *

     * @param value

     *     allowed object is

     *     {@link String }

     *    

     */

    public void setValidation(String value) {

        this.validation = value;

    }

 

    /**

     * Gets the value of the code property.

     *

     * @return

     *     possible object is

     *     {@link Integer }

     *    

     */

    public Integer getCode() {

        return code;

    }

 

    /**

     * Sets the value of the code property.

     *

     * @param value

     *     allowed object is

     *     {@link Integer }

     *    

     */

    public void setCode(Integer value) {

        this.code = value;

    }

 

    /**

     * Gets the value of the message property.

     *

     * @return

     *     possible object is

     *     {@link String }

     *    

     */

    public String getMessage() {

        return message;

    }

 

    /**

     * Sets the value of the message property.

     *

     * @param value

     *     allowed object is

     *     {@link String }

     *    

     */

    public void setMessage(String value) {

        this.message = value;

    }

 

 

    /**

     * <p>Java class for anonymous complex type.

     *

     * <p>The following schema fragment specifies the expected content contained within this class.

     *

     * <pre>

     * &lt;complexType>

     *   &lt;simpleContent>

     *     &lt;extension base="&lt;http://www.w3.org/2001/XMLSchema>string">

     *       &lt;attribute name="Modified" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />

     *       &lt;attribute name="UserID" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />

     *     &lt;/extension>

     *   &lt;/simpleContent>

     * &lt;/complexType>

     * </pre>

     *

     *

     */

    @XmlAccessorType(XmlAccessType.FIELD)

    @XmlType(name = "", propOrder = {

        "value"

    })

    public static class Narrative {

 

        @XmlValue

        protected String value;

        @XmlAttribute(name = "Modified", required = true)

        protected String modified;

        @XmlAttribute(name = "UserID", required = true)

        protected String userID;

 

        /**

         * Gets the value of the value property.

         *

         * @return

         *     possible object is

         *     {@link String }

         *    

         */

        public String getValue() {

            return value;

        }

 

        /**

         * Sets the value of the value property.

         *

         * @param value

         *     allowed object is

         *     {@link String }

         *    

         */

        public void setValue(String value) {

            this.value = value;

        }

 

        /**

         * Gets the value of the modified property.

         *

         * @return

         *     possible object is

         *     {@link String }

         *    

         */

        public String getModified() {

            return modified;

        }

 

        /**

         * Sets the value of the modified property.

         *

         * @param value

         *     allowed object is

         *     {@link String }

         *    

         */

        public void setModified(String value) {

            this.modified = value;

        }

 

        /**

         * Gets the value of the userID property.

         *

         * @return

         *     possible object is

         *     {@link String }

         *    

         */

        public String getUserID() {

            return userID;

        }

 

        /**

         * Sets the value of the userID property.

         *

         * @param value

         *     allowed object is

         *     {@link String }

         *    

         */

        public void setUserID(String value) {

            this.userID = value;

        }

 

    }

 

}

 

Client Generated code from a non-JaxB Object:

 

 

package test;

 

import javax.xml.bind.annotation.XmlAccessType;

import javax.xml.bind.annotation.XmlAccessorType;

import javax.xml.bind.annotation.XmlType;

 

 

/**

* <p>Java class for noJaxBWorkFlowSettings complex type.

*

 * <p>The following schema fragment specifies the expected content contained within this class.

*

 * <pre>

* &lt;complexType name="noJaxBWorkFlowSettings">

*   &lt;complexContent>

*     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">

*       &lt;sequence>

*         &lt;element name="code" type="{http://www.w3.org/2001/XMLSchema}int" minOccurs="0"/>

*         &lt;element name="dataFuse" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>

*         &lt;element name="message" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>

*         &lt;element name="narrative" type="{http://test/}noJaxBNarrative" minOccurs="0"/>

*         &lt;element name="validation" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>

*         &lt;element name="version" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>

*       &lt;/sequence>

*     &lt;/restriction>

*   &lt;/complexContent>

* &lt;/complexType>

* </pre>

*

 *

 */

@XmlAccessorType(XmlAccessType.FIELD)

@XmlType(name = "noJaxBWorkFlowSettings", propOrder = {

    "code",

    "dataFuse",

    "message",

    "narrative",

    "validation",

    "version"

})

public class NoJaxBWorkFlowSettings {

 

    protected Integer code;

    protected String dataFuse;

    protected String message;

    protected NoJaxBNarrative narrative;

    protected String validation;

    protected String version;

 

    /**

     * Gets the value of the code property.

     *

     * @return

     *     possible object is

     *     {@link Integer }

     *    

     */

    public Integer getCode() {

        return code;

    }

 

    /**

     * Sets the value of the code property.

     *

     * @param value

     *     allowed object is

     *     {@link Integer }

     *    

     */

    public void setCode(Integer value) {

        this.code = value;

    }

 

    /**

     * Gets the value of the dataFuse property.

     *

     * @return

     *     possible object is

     *     {@link String }

     *    

     */

    public String getDataFuse() {

        return dataFuse;

    }

 

    /**

     * Sets the value of the dataFuse property.

     *

     * @param value

     *     allowed object is

     *     {@link String }

     *    

     */

    public void setDataFuse(String value) {

        this.dataFuse = value;

    }

 

    /**

     * Gets the value of the message property.

     *

     * @return

     *     possible object is

     *     {@link String }

     *    

     */

    public String getMessage() {

        return message;

    }

 

    /**

     * Sets the value of the message property.

     *

     * @param value

     *     allowed object is

     *     {@link String }

     *    

     */

    public void setMessage(String value) {

        this.message = value;

    }

 

    /**

     * Gets the value of the narrative property.

     *

     * @return

     *     possible object is

     *     {@link NoJaxBNarrative }

     *    

     */

    public NoJaxBNarrative getNarrative() {

        return narrative;

    }

 

    /**

     * Sets the value of the narrative property.

     *

     * @param value

     *     allowed object is

     *     {@link NoJaxBNarrative }

     *    

     */

   public void setNarrative(NoJaxBNarrative value) {

        this.narrative = value;

    }

 

    /**

     * Gets the value of the validation property.

     *

     * @return

     *     possible object is

     *     {@link String }

     *    

     */

    public String getValidation() {

        return validation;

    }

 

    /**

     * Sets the value of the validation property.

     *

     * @param value

     *     allowed object is

     *     {@link String }

     *    

     */

    public void setValidation(String value) {

        this.validation = value;

    }

 

    /**

     * Gets the value of the version property.

     *

     * @return

     *     possible object is

     *     {@link String }

     *    

     */

    public String getVersion() {

        return version;

    }

 

    /**

     * Sets the value of the version property.

     *

     * @param value

     *     allowed object is

     *     {@link String }

     *    

     */

    public void setVersion(String value) {

        this.version = value;

    }

 

}

 

 

package test;

 

import javax.xml.bind.annotation.XmlAccessType;

import javax.xml.bind.annotation.XmlAccessorType;

import javax.xml.bind.annotation.XmlType;

 

 

/**

* <p>Java class for noJaxBNarrative complex type.

*

 * <p>The following schema fragment specifies the expected content contained within this class.

*

 * <pre>

* &lt;complexType name="noJaxBNarrative">

*   &lt;complexContent>

*     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">

*       &lt;sequence>

*         &lt;element name="modified" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>

*         &lt;element name="userID" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>

*         &lt;element name="value" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>

*       &lt;/sequence>

*     &lt;/restriction>

*   &lt;/complexContent>

* &lt;/complexType>

* </pre>

*

 *

 */

@XmlAccessorType(XmlAccessType.FIELD)

@XmlType(name = "noJaxBNarrative", propOrder = {

    "modified",

    "userID",

    "value"

})

public class NoJaxBNarrative {

 

    protected String modified;

    protected String userID;

    protected String value;

 

    /**

     * Gets the value of the modified property.

     *

     * @return

     *     possible object is

     *     {@link String }

     *    

     */

    public String getModified() {

        return modified;

    }

 

    /**

     * Sets the value of the modified property.

     *

     * @param value

     *     allowed object is

     *     {@link String }

     *    

     */

    public void setModified(String value) {

        this.modified = value;

    }

 

    /**

     * Gets the value of the userID property.

     *

     * @return

    *     possible object is

     *     {@link String }

     *    

     */

    public String getUserID() {

        return userID;

    }

 

    /**

     * Sets the value of the userID property.

     *

     * @param value

     *     allowed object is

     *     {@link String }

     *    

     */

    public void setUserID(String value) {

        this.userID = value;

    }

 

    /**

     * Gets the value of the value property.

     *

     * @return

     *     possible object is

     *     {@link String }

     *    

     */

    public String getValue() {

        return value;

    }

 

    /**

     * Sets the value of the value property.

     *

     * @param value

     *     allowed object is

     *     {@link String }

     *    

     */

    public void setValue(String value) {

        this.value = value;

    }

 

}

Scott Selvia
(O) <a href="tel:813.960.7800%20x102" value="+18139607800" target="_blank">813.960.7800 x102
(F) <a href="tel:813.960.7811" value="+18139607811" target="_blank">813.960.7811
http://www.datamentors.com

email_dm_logo

 




--
BEKK Open
http://open.bekk.no

TesTcl - a unit test framework for iRules
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: Returning a JaxB Object from a Web Service Generates a Nested Class on the Client

sselvia

Stefan,

 

We figured out the issue based on reading this stack overflow chain and do performing some proof of concept code.

 

http://stackoverflow.com/questions/14149121/why-does-wsimport-have-trouble-with-server-object-having-xmlrootelement-annotat?rq=1

 

As it turns out specifying the targetNamespace in the XSD along with the the @WebResult(name = “foo”, targetNamespace = “foo”) on our service methods that return a JaxB object and specifying the targetNamespace on the @WebParam(name = “foo”, targetNamespace = “foo”) for our methods that accept a JaxB object.  The generated client stubs no longer create a response object that generates a Return Object or an object nested within the generated response, they return and accept a foo object.

 

Regards,

 

Scott

 

From: Stefan Magnus Landrø [mailto:[hidden email]]
Sent: Tuesday, August 18, 2015 4:53 AM
To: [hidden email]
Subject: Re: Returning a JaxB Object from a Web Service Generates a Nested Class on the Client

 

More details, please.

Could you please provide the WSDL and the command you use?

Also - I would recommend generating stubs using maven, gradle or ant or whatever instead of doing this in netbeans.

Stefan

 

 

2015-08-17 21:49 GMT+02:00 Scott Selvia <[hidden email]>:

When returning an object that is already annotated with JaxB annotations the generated Client classes using wsimport via Netbeans has the objects nested within the root element class.  If the JaxB annotations do not exist for the returned object the resulting object and objects contained inside are not nested together.  What are the necessary switches to get wsimport to not generate the nested classes?

 

Client Generated code of a JaxB returned Object:

 

package test;

 

import javax.xml.bind.annotation.XmlAccessType;

import javax.xml.bind.annotation.XmlAccessorType;

import javax.xml.bind.annotation.XmlAttribute;

import javax.xml.bind.annotation.XmlElement;

import javax.xml.bind.annotation.XmlRootElement;

import javax.xml.bind.annotation.XmlType;

import javax.xml.bind.annotation.XmlValue;

 

 

/**

* <p>Java class for anonymous complex type.

*

 * <p>The following schema fragment specifies the expected content contained within this class.

*

 * <pre>

* &lt;complexType>

*   &lt;complexContent>

*     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">

*       &lt;sequence>

*         &lt;element name="Narrative">

*           &lt;complexType>

*             &lt;simpleContent>

*               &lt;extension base="&lt;http://www.w3.org/2001/XMLSchema>string">

*                 &lt;attribute name="Modified" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />

*                 &lt;attribute name="UserID" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />

*               &lt;/extension>

*             &lt;/simpleContent>

*           &lt;/complexType>

*         &lt;/element>

*       &lt;/sequence>

*       &lt;attribute name="DataFuse" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />

*       &lt;attribute name="Version" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />

*       &lt;attribute name="Validation" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />

*       &lt;attribute name="Code" type="{http://www.w3.org/2001/XMLSchema}int" />

*       &lt;attribute name="Message" type="{http://www.w3.org/2001/XMLSchema}string" />

*     &lt;/restriction>

*   &lt;/complexContent>

* &lt;/complexType>

* </pre>

*

 *

 */

@XmlAccessorType(XmlAccessType.FIELD)

@XmlType(name = "", propOrder = {

    "narrative"

})

@XmlRootElement(name = "WorkFlowSettings")

public class WorkFlowSettings {

 

    @XmlElement(name = "Narrative", required = true)

    protected WorkFlowSettings.Narrative narrative;

    @XmlAttribute(name = "DataFuse", required = true)

    protected String dataFuse;

    @XmlAttribute(name = "Version", required = true)

    protected String version;

    @XmlAttribute(name = "Validation", required = true)

    protected String validation;

    @XmlAttribute(name = "Code")

    protected Integer code;

    @XmlAttribute(name = "Message")

    protected String message;

 

    /**

     * Gets the value of the narrative property.

     *

     * @return

     *     possible object is

     *     {@link WorkFlowSettings.Narrative }

     *    

     */

    public WorkFlowSettings.Narrative getNarrative() {

        return narrative;

    }

 

    /**

     * Sets the value of the narrative property.

     *

     * @param value

     *     allowed object is

     *     {@link WorkFlowSettings.Narrative }

     *    

     */

    public void setNarrative(WorkFlowSettings.Narrative value) {

        this.narrative = value;

    }

 

    /**

     * Gets the value of the dataFuse property.

     *

     * @return

     *     possible object is

     *     {@link String }

     *    

     */

    public String getDataFuse() {

        return dataFuse;

    }

 

    /**

     * Sets the value of the dataFuse property.

     *

     * @param value

     *     allowed object is

     *     {@link String }

     *    

     */

    public void setDataFuse(String value) {

        this.dataFuse = value;

    }

 

    /**

     * Gets the value of the version property.

     *

     * @return

     *     possible object is

     *     {@link String }

     *    

     */

    public String getVersion() {

        return version;

    }

 

    /**

     * Sets the value of the version property.

     *

     * @param value

     *     allowed object is

     *     {@link String }

     *    

     */

    public void setVersion(String value) {

        this.version = value;

    }

 

    /**

     * Gets the value of the validation property.

     *

     * @return

     *     possible object is

     *     {@link String }

     *    

     */

    public String getValidation() {

        return validation;

    }

 

    /**

     * Sets the value of the validation property.

     *

     * @param value

     *     allowed object is

     *     {@link String }

     *    

     */

    public void setValidation(String value) {

        this.validation = value;

    }

 

    /**

     * Gets the value of the code property.

     *

     * @return

     *     possible object is

     *     {@link Integer }

     *    

     */

    public Integer getCode() {

        return code;

    }

 

    /**

     * Sets the value of the code property.

     *

     * @param value

     *     allowed object is

     *     {@link Integer }

     *    

     */

    public void setCode(Integer value) {

        this.code = value;

    }

 

    /**

     * Gets the value of the message property.

     *

     * @return

     *     possible object is

     *     {@link String }

     *    

     */

    public String getMessage() {

        return message;

    }

 

    /**

     * Sets the value of the message property.

     *

     * @param value

     *     allowed object is

     *     {@link String }

     *    

     */

    public void setMessage(String value) {

        this.message = value;

    }

 

 

    /**

     * <p>Java class for anonymous complex type.

     *

     * <p>The following schema fragment specifies the expected content contained within this class.

     *

     * <pre>

     * &lt;complexType>

     *   &lt;simpleContent>

     *     &lt;extension base="&lt;http://www.w3.org/2001/XMLSchema>string">

     *       &lt;attribute name="Modified" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />

     *       &lt;attribute name="UserID" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />

     *     &lt;/extension>

     *   &lt;/simpleContent>

     * &lt;/complexType>

     * </pre>

     *

     *

     */

    @XmlAccessorType(XmlAccessType.FIELD)

    @XmlType(name = "", propOrder = {

        "value"

    })

    public static class Narrative {

 

        @XmlValue

        protected String value;

        @XmlAttribute(name = "Modified", required = true)

        protected String modified;

        @XmlAttribute(name = "UserID", required = true)

        protected String userID;

 

        /**

         * Gets the value of the value property.

         *

         * @return

         *     possible object is

         *     {@link String }

         *    

         */

        public String getValue() {

            return value;

        }

 

        /**

         * Sets the value of the value property.

         *

         * @param value

         *     allowed object is

         *     {@link String }

         *    

         */

        public void setValue(String value) {

            this.value = value;

        }

 

        /**

         * Gets the value of the modified property.

         *

         * @return

         *     possible object is

         *     {@link String }

         *    

         */

        public String getModified() {

            return modified;

        }

 

        /**

         * Sets the value of the modified property.

         *

         * @param value

         *     allowed object is

         *     {@link String }

         *    

         */

        public void setModified(String value) {

            this.modified = value;

        }

 

        /**

         * Gets the value of the userID property.

         *

         * @return

         *     possible object is

         *     {@link String }

         *    

         */

        public String getUserID() {

            return userID;

        }

 

        /**

         * Sets the value of the userID property.

         *

         * @param value

         *     allowed object is

         *     {@link String }

         *    

         */

        public void setUserID(String value) {

            this.userID = value;

        }

 

    }

 

}

 

Client Generated code from a non-JaxB Object:

 

 

package test;

 

import javax.xml.bind.annotation.XmlAccessType;

import javax.xml.bind.annotation.XmlAccessorType;

import javax.xml.bind.annotation.XmlType;

 

 

/**

* <p>Java class for noJaxBWorkFlowSettings complex type.

*

 * <p>The following schema fragment specifies the expected content contained within this class.

*

 * <pre>

* &lt;complexType name="noJaxBWorkFlowSettings">

*   &lt;complexContent>

*     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">

*       &lt;sequence>

*         &lt;element name="code" type="{http://www.w3.org/2001/XMLSchema}int" minOccurs="0"/>

*         &lt;element name="dataFuse" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>

*         &lt;element name="message" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>

*         &lt;element name="narrative" type="{http://test/}noJaxBNarrative" minOccurs="0"/>

*         &lt;element name="validation" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>

*         &lt;element name="version" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>

*       &lt;/sequence>

*     &lt;/restriction>

*   &lt;/complexContent>

* &lt;/complexType>

* </pre>

*

 *

 */

@XmlAccessorType(XmlAccessType.FIELD)

@XmlType(name = "noJaxBWorkFlowSettings", propOrder = {

    "code",

    "dataFuse",

    "message",

    "narrative",

    "validation",

    "version"

})

public class NoJaxBWorkFlowSettings {

 

    protected Integer code;

    protected String dataFuse;

    protected String message;

    protected NoJaxBNarrative narrative;

    protected String validation;

    protected String version;

 

    /**

     * Gets the value of the code property.

     *

     * @return

     *     possible object is

     *     {@link Integer }

     *    

     */

    public Integer getCode() {

        return code;

    }

 

    /**

     * Sets the value of the code property.

     *

     * @param value

     *     allowed object is

     *     {@link Integer }

     *    

     */

    public void setCode(Integer value) {

        this.code = value;

    }

 

    /**

     * Gets the value of the dataFuse property.

     *

     * @return

     *     possible object is

     *     {@link String }

     *    

     */

    public String getDataFuse() {

        return dataFuse;

    }

 

    /**

     * Sets the value of the dataFuse property.

     *

     * @param value

     *     allowed object is

     *     {@link String }

     *    

     */

    public void setDataFuse(String value) {

        this.dataFuse = value;

    }

 

    /**

     * Gets the value of the message property.

     *

     * @return

     *     possible object is

     *     {@link String }

     *    

     */

    public String getMessage() {

        return message;

    }

 

    /**

     * Sets the value of the message property.

     *

     * @param value

     *     allowed object is

     *     {@link String }

     *    

     */

    public void setMessage(String value) {

        this.message = value;

    }

 

    /**

     * Gets the value of the narrative property.

     *

     * @return

     *     possible object is

     *     {@link NoJaxBNarrative }

     *    

     */

    public NoJaxBNarrative getNarrative() {

        return narrative;

    }

 

    /**

     * Sets the value of the narrative property.

     *

     * @param value

     *     allowed object is

     *     {@link NoJaxBNarrative }

     *    

     */

   public void setNarrative(NoJaxBNarrative value) {

        this.narrative = value;

    }

 

    /**

     * Gets the value of the validation property.

     *

     * @return

     *     possible object is

     *     {@link String }

     *    

     */

    public String getValidation() {

        return validation;

    }

 

    /**

     * Sets the value of the validation property.

     *

     * @param value

     *     allowed object is

     *     {@link String }

     *    

     */

    public void setValidation(String value) {

        this.validation = value;

    }

 

    /**

     * Gets the value of the version property.

     *

     * @return

     *     possible object is

     *     {@link String }

     *    

     */

    public String getVersion() {

        return version;

    }

 

    /**

     * Sets the value of the version property.

     *

     * @param value

     *     allowed object is

     *     {@link String }

     *    

     */

    public void setVersion(String value) {

        this.version = value;

    }

 

}

 

 

package test;

 

import javax.xml.bind.annotation.XmlAccessType;

import javax.xml.bind.annotation.XmlAccessorType;

import javax.xml.bind.annotation.XmlType;

 

 

/**

* <p>Java class for noJaxBNarrative complex type.

*

 * <p>The following schema fragment specifies the expected content contained within this class.

*

 * <pre>

* &lt;complexType name="noJaxBNarrative">

*   &lt;complexContent>

*     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">

*       &lt;sequence>

*         &lt;element name="modified" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>

*         &lt;element name="userID" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>

*         &lt;element name="value" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>

*       &lt;/sequence>

*     &lt;/restriction>

*   &lt;/complexContent>

* &lt;/complexType>

* </pre>

*

 *

 */

@XmlAccessorType(XmlAccessType.FIELD)

@XmlType(name = "noJaxBNarrative", propOrder = {

    "modified",

    "userID",

    "value"

})

public class NoJaxBNarrative {

 

    protected String modified;

    protected String userID;

    protected String value;

 

    /**

     * Gets the value of the modified property.

     *

     * @return

     *     possible object is

     *     {@link String }

     *    

     */

    public String getModified() {

        return modified;

    }

 

    /**

     * Sets the value of the modified property.

     *

     * @param value

     *     allowed object is

     *     {@link String }

     *    

     */

    public void setModified(String value) {

        this.modified = value;

    }

 

    /**

     * Gets the value of the userID property.

     *

     * @return

    *     possible object is

     *     {@link String }

     *    

     */

    public String getUserID() {

        return userID;

    }

 

    /**

     * Sets the value of the userID property.

     *

     * @param value

     *     allowed object is

     *     {@link String }

     *    

     */

    public void setUserID(String value) {

        this.userID = value;

    }

 

    /**

     * Gets the value of the value property.

     *

     * @return

     *     possible object is

     *     {@link String }

     *    

     */

    public String getValue() {

        return value;

    }

 

    /**

     * Sets the value of the value property.

     *

     * @param value

     *     allowed object is

     *     {@link String }

     *    

     */

    public void setValue(String value) {

        this.value = value;

    }

 

}

Scott Selvia
(O) <a href="tel:813.960.7800%20x102" target="_blank">813.960.7800 x102
(F) <a href="tel:813.960.7811" target="_blank">813.960.7811
http://www.datamentors.com

email_dm_logo

 




--

BEKK Open
http://open.bekk.no

 

TesTcl - a unit test framework for iRules

Loading...