Blame view

src/th/co/ais/ssbsrfc/control/TestMain.java 4.64 KB
1048b156   Suraputt Suntimitr   Template
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
package th.co.ais.ssbsrfc.control;

import java.util.List;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.Unmarshaller;
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.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamReader;
import javax.xml.transform.stream.StreamSource;


@XmlAccessorType(XmlAccessType.FIELD)
class Customer {

    @XmlElement(name="Version",namespace="http://www.huawei.com/bme/cbsinterface/cbscommon")
    String Version;
    @XmlElement(name="ResultCode",namespace="http://www.huawei.com/bme/cbsinterface/cbscommon")
    String ResultCode;
    @XmlElement(name="MsgLanguageCode",namespace="http://www.huawei.com/bme/cbsinterface/cbscommon")
    String MsgLanguageCode;
    @XmlElement(name="ResultDesc",namespace="http://www.huawei.com/bme/cbsinterface/cbscommon")
    String ResultDesc;
    @XmlElement(name="AcctKey",namespace="http://www.huawei.com/bme/cbsinterface/arservices")
    String AcctKey;
    
    @XmlElement(name="AdjustmentInfo",namespace="http://www.huawei.com/bme/cbsinterface/arservices")
    List<AdjustmentInfo> AdjustmentInfo;
}
class AdjustmentInfo{

	String BalanceType;
	String BalanceID;
	String BalanceTypeName;
	String OldBalanceAmt;
	String NewBalanceAmt;
	String CurrencyID;
	
	@XmlElement(name="BalanceID",namespace="http://cbs.huawei.com/ar/wsservice/arcommon")
	public String getBalanceID() {
		return BalanceID;
	}

	public void setBalanceID(String balanceID) {
		BalanceID = balanceID;
	}

	@XmlElement(name="BalanceTypeName",namespace="http://cbs.huawei.com/ar/wsservice/arcommon")
	public String getBalanceTypeName() {
		return BalanceTypeName;
	}

	public void setBalanceTypeName(String balanceTypeName) {
		BalanceTypeName = balanceTypeName;
	}

	@XmlElement(name="OldBalanceAmt",namespace="http://cbs.huawei.com/ar/wsservice/arcommon")
	public String getOldBalanceAmt() {
		return OldBalanceAmt;
	}

	public void setOldBalanceAmt(String oldBalanceAmt) {
		OldBalanceAmt = oldBalanceAmt;
	}

	@XmlElement(name="NewBalanceAmt",namespace="http://cbs.huawei.com/ar/wsservice/arcommon")
	public String getNewBalanceAmt() {
		return NewBalanceAmt;
	}

	public void setNewBalanceAmt(String newBalanceAmt) {
		NewBalanceAmt = newBalanceAmt;
	}

	@XmlElement(name="CurrencyID",namespace="http://cbs.huawei.com/ar/wsservice/arcommon")
	public String getCurrencyID() {
		return CurrencyID;
	}

	public void setCurrencyID(String currencyID) {
		CurrencyID = currencyID;
	}

	@XmlElement(name="BalanceType",namespace="http://cbs.huawei.com/ar/wsservice/arcommon")
	public String getBalanceType() {
		return BalanceType;
	}

	public void setBalanceType(String BalanceType) {
		this.BalanceType = BalanceType;
	}
	
	
}


public class TestMain {

	public static void main(String[] args) throws Exception {

        XMLInputFactory xif = XMLInputFactory.newFactory();
        StreamSource xml = new StreamSource("D:\\car.xml");
        XMLStreamReader xsr = xif.createXMLStreamReader(xml);
        xsr.nextTag();
        while(!xsr.getLocalName().equals("ResultHeader")) {
            xsr.nextTag();
            System.out.println(xsr.getLocalName());
            System.out.println(xsr.hasNext());
        }
        System.out.println(xsr.hasNext());
        xsr.next();
        /*while(!xsr.getLocalName().equals("AdjustmentResult")) {
            xsr.nextTag();
        }*/
        
        JAXBContext jc = JAXBContext.newInstance(Customer.class);
        Unmarshaller unmarshaller = jc.createUnmarshaller();
        JAXBElement<Customer> jb = unmarshaller.unmarshal(xsr, Customer.class);
        xsr.close();
 
        Customer customer = jb.getValue();
        System.out.println("Version:"+customer.Version);
        System.out.println("ResultCode:"+customer.ResultCode);
        System.out.println("MsgLanguageCode:"+customer.MsgLanguageCode);
        System.out.println("ResultDesc:"+customer.ResultDesc);
        /*System.out.println("AcctKey:"+customer.AcctKey);
        System.out.println("BalanceID:"+customer.AdjustmentInfo.get(0).getBalanceID());
        System.out.println("BalanceType:"+customer.AdjustmentInfo.get(0).getBalanceType());
        System.out.println("BalanceTypeName:"+customer.AdjustmentInfo.get(0).getBalanceTypeName());
        System.out.println("CurrencyID:"+customer.AdjustmentInfo.get(0).CurrencyID);
        System.out.println("NewBalanceAmt:"+customer.AdjustmentInfo.get(0).NewBalanceAmt);
        System.out.println("OldBalanceAmt:"+customer.AdjustmentInfo.get(0).OldBalanceAmt);*/
        
        
	}
}