【发布时间】:2016-05-08 12:57:58
【问题描述】:
好的,所以我得到以下肥皂响应:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<GetCustomerDetailsByDeviceNumberResponse xmlns="http://services.domain.com/SelfCare">
<GetCustomerDetailsByDeviceNumberResult xmlns:a="http://datacontracts.domain.com/SelfCare"
xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<a:AuditReferenceNumber i:nil="true"/>
<a:accounts>
<a:Account>
<a:lastInvoiceAmount>0</a:lastInvoiceAmount>
<a:lastInvoiceDate>0001-01-01T00:00:00</a:lastInvoiceDate>
</a:Account>
</a:accounts>
</GetCustomerDetailsByDeviceNumberResult>
</GetCustomerDetailsByDeviceNumberResponse>
</s:Body>
</s:Envelope>
我正在尝试使用这段代码获取<a:lastInvoiceDate></a:lastInvoiceDate> 的值:
SOAPBody sBody = response.getSOAPBody();
QName gcdbdbr = new QName("http://services.domain.com/SelfCare", "GetCustomerDetailsByDeviceNumberResponse");
java.util.Iterator iterator = sBody.getChildElements(gcdbdbr);
while(iterator.hasNext()){
NodeList nodeList = sBody.getElementsByTagName("lastInvoiceDate");
Element element = (Element) nodeList.item(0);
Node child = element.getFirstChild();
String data = child.getTextContent();
System.out.println(data);
}
但它是空的。
如何获得<a:lastInvoiceDate> 的值?
【问题讨论】: