title: How to expose custom object in web service
body: <p>How can I expose an custom object as parameter in a class using web services?</p>
  
  <p>For example, I have a class called <code>OrderWS.java</code> and in that class I have <code>OrderLineWS.java</code> as parameter. Now when I exposed this <code>OrderWS.java</code> to web services on client side. It did not include <code>OrderLineWS</code> as parameter to <code>OrderWS</code> class on client side. Can anybody help me please?</p>
  
  <p>OrderWS.java</p>
  
  <pre><code>package com.dev.backend.order;
  
  import java.io.Serializable;
  import java.math.BigDecimal;
  import java.util.ArrayList;
  import java.util.HashSet;
  import java.util.List;
  import java.util.Set;
  
  import com.dev.backend.customer.CustomerWS;
  
  public class OrderWS implements Serializable{
  
      private String orderNumber;
      private String customerCode ;
      private BigDecimal totalPrice;
      private List&lt;OrderLineWS&gt; orderLineWSs = new ArrayList&lt;OrderLineWS&gt;();
  
      public String getOrderNumber() {
          return orderNumber;
      }
      public void setOrderNumber(String orderNumber) {
          this.orderNumber = orderNumber;
      }
      public String getCustomerCode() {
          return customerCode;
      }
      public void setCustomerCode(String customerCode) {
          this.customerCode = customerCode;
      }
      public BigDecimal getTotalPrice() {
          return totalPrice;
      }
      public void setTotalPrice(BigDecimal totalPrice) {
          this.totalPrice = totalPrice;
      }
      public List&lt;OrderLineWS&gt; getOrderLineWSs() {
          return orderLineWSs;
      }
      public void setOerLineWSs(List&lt;OrderLineWS&gt; orderLineWSs) {
          this.orderLineWSs = orderLineWSs;
      }
  
  }
  </code></pre>
  
  <p>OrderLineWS.java</p>
  
  <pre><code>package com.dev.backend.order;
  
  import java.io.Serializable;
  import java.math.BigDecimal;
  
  import javax.xml.bind.annotation.XmlAccessType;
  import javax.xml.bind.annotation.XmlAccessorType;
  import javax.xml.bind.annotation.XmlRootElement;
  
  import com.dev.backend.product.ProductWS;
  
  @XmlRootElement
  @XmlAccessorType(XmlAccessType.FIELD)
  public class OrderLineWS implements Serializable{
  
      private Integer quantity;
      private BigDecimal unitPrice;
      private BigDecimal totalPrice;
      private String productCode;
      private String orderCode;
  
      public Integer getQuantity() {
          return quantity;
      }
      public void setQuantity(Integer quantity) {
          this.quantity = quantity;
      }
      public BigDecimal getUnitPrice() {
          return unitPrice;
      }
      public void setUnitPrice(BigDecimal unitPrice) {
          this.unitPrice = unitPrice;
      }
      public BigDecimal getTotalPrice() {
          return totalPrice;
      }
      public void setTotalPrice(BigDecimal totalPrice) {
          this.totalPrice = totalPrice;
      }
      public String getProductCode() {
          return productCode;
      }
      public void setProductCode(String productCode) {
          this.productCode = productCode;
      }
      public String getOrderCode() {
          return orderCode;
      }
      public void setOrderCode(String orderCode) {
          this.orderCode = orderCode;
      }
  
  }
  </code></pre>
  
  <p>IWebService.java</p>
  
  <pre><code>package com.dev.backend.webservices;
  
  import javax.jws.WebMethod;
  import javax.jws.WebService;
  
  import com.dev.backend.customer.CustomerWS;
  import com.dev.backend.order.OrderWS;
  import com.dev.backend.product.ProductWS;
  
  @WebService
  public interface IWebService {
  
      @WebMethod
      Integer saveOrder(OrderWS orderWS);
  }
  </code></pre>
  
  <p>I generated classes on client side using this command</p>
  
  <pre><code>wsimport -Xnocompile . http://localhost:8080/WS/IWebService?wsdl
  </code></pre>
  
  <p>On client side OrderWS.java is generated like this</p>
  
  <pre><code>package com.dev.backend.webservices;
  
  import java.math.BigDecimal;
  import javax.xml.bind.annotation.XmlAccessType;
  import javax.xml.bind.annotation.XmlAccessorType;
  import javax.xml.bind.annotation.XmlType;
  
  
  /**
   * &lt;p&gt;Java class for orderWS complex type.
   * 
   * &lt;p&gt;The following schema fragment specifies the expected content contained within this class.
   * 
   * &lt;pre&gt;
   * &amp;lt;complexType name="orderWS"&gt;
   *   &amp;lt;complexContent&gt;
   *     &amp;lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"&gt;
   *       &amp;lt;sequence&gt;
   *         &amp;lt;element name="customerCode" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/&gt;
   *         &amp;lt;element name="orderNumber" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/&gt;
   *         &amp;lt;element name="totalPrice" type="{http://www.w3.org/2001/XMLSchema}decimal" minOccurs="0"/&gt;
   *       &amp;lt;/sequence&gt;
   *     &amp;lt;/restriction&gt;
   *   &amp;lt;/complexContent&gt;
   * &amp;lt;/complexType&gt;
   * &lt;/pre&gt;
   * 
   * 
   */
  @XmlAccessorType(XmlAccessType.FIELD)
  @XmlType(name = "orderWS", propOrder = {
      "customerCode",
      "orderNumber",
      "totalPrice"
  })
  public class OrderWS {
  
      protected String customerCode;
      protected String orderNumber;
      protected BigDecimal totalPrice;
  
      /**
       * Gets the value of the customerCode property.
       * 
       * @return
       *     possible object is
       *     {@link String }
       *     
       */
      public String getCustomerCode() {
          return customerCode;
      }
  
      /**
       * Sets the value of the customerCode property.
       * 
       * @param value
       *     allowed object is
       *     {@link String }
       *     
       */
      public void setCustomerCode(String value) {
          this.customerCode = value;
      }
  
      /**
       * Gets the value of the orderNumber property.
       * 
       * @return
       *     possible object is
       *     {@link String }
       *     
       */
      public String getOrderNumber() {
          return orderNumber;
      }
  
      /**
       * Sets the value of the orderNumber property.
       * 
       * @param value
       *     allowed object is
       *     {@link String }
       *     
       */
      public void setOrderNumber(String value) {
          this.orderNumber = value;
      }
  
      /**
       * Gets the value of the totalPrice property.
       * 
       * @return
       *     possible object is
       *     {@link BigDecimal }
       *     
       */
      public BigDecimal getTotalPrice() {
          return totalPrice;
      }
  
      /**
       * Sets the value of the totalPrice property.
       * 
       * @param value
       *     allowed object is
       *     {@link BigDecimal }
       *     
       */
      public void setTotalPrice(BigDecimal value) {
          this.totalPrice = value;
      }
  
  }
  </code></pre>