JAXB问题数组不映射

时间:2014-11-19 21:58:16

标签: java xml jaxb

有谁能告诉我为什么产品没有映射? (总是空的)我使用JAXB进行编组

XML

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <soap:Body>
      <getAccountProductsResponse xmlns="http://CellucomPosa/">
         <getAccountProductsResult>
            <CellucomPOSA xmlns="">
               <Product>
                  <ProductID>280</ProductID>
                  <ProductName>AT&amp;T $15</ProductName>
                  <Discount>18</Discount>
                  <Price>15.00</Price>
                  <ProdType>PINRTR</ProdType>
               </Product>
               <Product>
                  <ProductID>281</ProductID>
                  <ProductName>AT&amp;T $25</ProductName>
                  <Discount>18</Discount>
                  <Price>25.00</Price>
                  <ProdType>PINRTR</ProdType>
               </Product>
            </CellucomPOSA>
         </getAccountProductsResult>
      </getAccountProductsResponse>
   </soap:Body>
</soap:Envelope>

这是我的POJO
    包cellucomposa;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAnyElement;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlMixed;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "getAccountProductsResult"
})
@XmlRootElement(name = "getAccountProductsResponse")
public class GetAccountProductsResponse {

    protected GetAccountProductsResponse.GetAccountProductsResult getAccountProductsResult;

    public GetAccountProductsResponse.GetAccountProductsResult getGetAccountProductsResult() {
        return getAccountProductsResult;
    }


    public void setGetAccountProductsResult(GetAccountProductsResponse.GetAccountProductsResult value) {
        this.getAccountProductsResult = value;
    }



    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "", propOrder = {
        "CellucomPOSA"
    })
    public static class GetAccountProductsResult {

        @XmlElement(namespace="")
        protected GetAccountProductsResponse.GetAccountProductsResult.CellucomPOSA CellucomPOSA;

        public GetAccountProductsResponse.GetAccountProductsResult.CellucomPOSA getCellucomPOSA() {
            return CellucomPOSA;
        }

        public void setCellucomPOSA(
                GetAccountProductsResponse.GetAccountProductsResult.CellucomPOSA cellucomPOSA) {
            this.CellucomPOSA = cellucomPOSA;
        }


        @XmlAccessorType(XmlAccessType.FIELD)
        @XmlType(name = "", propOrder = {
            "Product"
        })
        public static class CellucomPOSA {

            protected GetAccountProductsResponse.GetAccountProductsResult.CellucomPOSA.Product[] Product;

            public GetAccountProductsResponse.GetAccountProductsResult.CellucomPOSA.Product[] getProduct() {
                return Product;
            }

            public void setProduct(
                    GetAccountProductsResponse.GetAccountProductsResult.CellucomPOSA.Product[] product) {
                this.Product = product;
            }

            @XmlAccessorType(XmlAccessType.FIELD)
            public static class Product {

                @XmlElement(name = "ProductID")
                protected int productID;

                @XmlElement(name = "ProductName")
                protected String ProductName;

                @XmlElement(name = "Discount")
                protected String discount;

                @XmlElement(name = "Price")
                protected String price;

                @XmlElement(name = "ProdType")
                protected String prodType;

                public int getProductID() {
                    return productID;
                }

                public void setProductID(int productID) {
                    this.productID = productID;
                }

                public String getProductName() {
                    return ProductName;
                }

                public void setProductName(String productName) {
                    ProductName = productName;
                }

                public String getDiscount() {
                    return discount;
                }

                public void setDiscount(String discount) {
                    this.discount = discount;
                }

                public String getPrice() {
                    return price;
                }

                public void setPrice(String price) {
                    this.price = price;
                }

                public String getProdType() {
                    return prodType;
                }

                public void setProdType(String prodType) {
                    this.prodType = prodType;
                }                   
            }               
        }    
    }  
}

我已经尝试了所有我能想到的东西,我们将非常感谢任何帮助,是否缺少某些东西

好的,在我有用的评论后,我发现正确的映射到底是什么解决方案到目前为止,一个问题虽然所有ProductID都没有映射任何人都有任何想法

package cellucomposa;

import java.util.List;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlID;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;


@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "getAccountProductsResult"
})
@XmlRootElement(name = "getAccountProductsResponse")
public class GetAccountProductsResponse {

    protected GetAccountProductsResponse.GetAccountProductsResult getAccountProductsResult;

    public GetAccountProductsResponse.GetAccountProductsResult getGetAccountProductsResult() {
        return getAccountProductsResult;
    }

    public void setGetAccountProductsResult(GetAccountProductsResponse.GetAccountProductsResult value) {
        this.getAccountProductsResult = value;
    }



    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "", propOrder = {
        "CellucomPOSA"
    })
    public static class GetAccountProductsResult {

        @XmlElement(namespace="")
        protected GetAccountProductsResponse.GetAccountProductsResult.CellucomPOSA CellucomPOSA;

        public GetAccountProductsResponse.GetAccountProductsResult.CellucomPOSA getCellucomPOSA() {
            return CellucomPOSA;
        }

        public void setCellucomPOSA(
                GetAccountProductsResponse.GetAccountProductsResult.CellucomPOSA cellucomPOSA) {
            this.CellucomPOSA = cellucomPOSA;
        }


        @XmlAccessorType(XmlAccessType.FIELD)
        @XmlType(name = "", propOrder = {
            "Product"
        })
        public static class CellucomPOSA {

            @XmlElement(namespace="")
            protected List<GetAccountProductsResponse.GetAccountProductsResult.CellucomPOSA.Product> Product;

            public List<GetAccountProductsResponse.GetAccountProductsResult.CellucomPOSA.Product> getProduct() {
                return Product;
            }

            public void setProduct(
                    List<GetAccountProductsResponse.GetAccountProductsResult.CellucomPOSA.Product> product) {
                this.Product = product;
            }

            @XmlAccessorType(XmlAccessType.FIELD)
            @XmlType(name = "", propOrder = {
                    "ProductID",
                    "ProductName",
                    "Discount",
                    "Price",
                    "ProdType"
                })
            public static class Product {

                @XmlElement(name="ProductId", namespace="")
                protected int ProductID;

                @XmlElement(name="ProductName", namespace="")
                protected String ProductName;

                @XmlElement(name="Discount", namespace="")
                protected String Discount;

                @XmlElement(name="Price", namespace="")
                protected String Price;

                @XmlElement(name="ProdType", namespace="")
                protected String ProdType;

                public int getProductID() {
                    return ProductID;
                }

                public void setProductID(int productID) {
                    this.ProductID = productID;
                }

                public String getProductName() {
                    return ProductName;
                }

                public void setProductName(String productName) {
                    ProductName = productName;
                }

                public String getDiscount() {
                    return Discount;
                }

                public void setDiscount(String discount) {
                    this.Discount = discount;
                }

                public String getPrice() {
                    return Price;
                }

                public void setPrice(String price) {
                    this.Price = price;
                }

                public String getProdType() {
                    return ProdType;
                }

                public void setProdType(String prodType) {
                    this.ProdType = prodType;
                }

            }

        }

    }

}

0 个答案:

没有答案