嗨,我是很新的XML,Web服務和但我從SOAP Web服務,看起來有點像這樣recieving XML:解組對象的數組和數組
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<ArrayOfCreditCardSettlement xmlns="http://schemas.datacontract.org/2004/07/Borgun.Library.Common">
<ns0:CreditCardSettlement xmlns="http://Borgun.Services.Gateway/2010/04/Settlement" xmlns:a="http://schemas.datacontract.org/2004/07/Borgun.Library.Common" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:msgns="http://Borgun.Services.Gateway/2010/04/Settlement" xmlns:ns0="http://schemas.datacontract.org/2004/07/Borgun.Library.Common" xmlns:ns1="http://j2ee.netbeans.org/wsdl/BorgunTestBPEL/entrypoint_getSettlements">
<a:amexAmount>**</a:amexAmount>
<a:amount>**</a:amount>
<a:batches>
<a:CreditCardBatch>
<a:batchdate>***</a:batchdate>
<a:batchnumber>***</a:batchnumber>
<a:currencyCode>***</a:currencyCode>
<a:merchantnumber>***</a:merchantnumber>
<a:settlementRunNumber>***</a:settlementRunNumber>
<a:settlementdate>***</a:settlementdate>
<a:slips>*</a:slips>
<a:sum>***</a:sum>
</a:CreditCardBatch>
.
.
more batches
<a:deductionItems>
<a:CreditCardSettlementDeduction>
<a:amount>***</a:amount>
<a:code>**</a:code>
<a:currencyCode>**</a:currencyCode>
<a:merchantnumber>***</a:merchantnumber>
<a:settlementrunnumber>***</a:settlementrunnumber>
<a:text>***</a:text>
</a:CreditCardSettlementDeduction>
.
. more deductionitems
</ns0:CreditCardSettlement>
.
. more Settlements
我用Netbeans的創建結合JAXB這似乎工作
try
{
JAXBContext jc = JAXBContext.newInstance("is.skyrr.jaxbbinding");
Unmarshaller unmarshaller = jc.createUnmarshaller();
Object o = (Object) unmarshaller.unmarshal(new File("....response3.xml"));
} catch (JAXBException ex)
{
Logger.getLogger(TestDB.class.getName()).log(Level.SEVERE, null, ex);
}
結合被生成,具有「ArrayOfCreditCardSettlement」,「CreditCardSettlement」和ObjectFactory的等。
現在,我可以在這裏做的唯一事情就是投向JAXBElement
即JAXBElement a =(JAXBElement)unmarshaller.unmarshal(new File(「... response3.xml」));
也許這就是我應該有的,但從那我該怎麼用這個?
我想要那個數組/列表使用,但我不知道下一步該怎麼做。
AdditionalInfo: 結合從一個xsd
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ArrayOfCreditCardSettlement", propOrder = {
"creditCardSettlement"})
public class ArrayOfCreditCardSettlement {
@XmlElement(name = "CreditCardSettlement", nillable = true)
protected List<CreditCardSettlement> creditCardSettlement;
public List<CreditCardSettlement> getCreditCardSettlement() {
if (creditCardSettlement == null) {
creditCardSettlement = new ArrayList<CreditCardSettlement>();
}
return this.creditCardSettlement;
}
爲CreditCardSettlement類相似生成。
對象工廠擁有XmlElementDecl將的明確命名的命名空間等來回
非常感謝,價值的東西只是完全迴避我的視線 – fogedi 2010-06-03 12:17:48