public SOAPFaultDataReader(JAXBDataBindingCallback cb) {
callback = cb;
}
public Object read(QName name, int idx, T input) {
SOAPFault fault = (SOAPFault)input;
if (fault.getDetail() != null) {
NodeList list = fault.getDetail().getChildNodes();
QName faultName;
for (int i = 0; i < list.getLength(); i++) {
Node entry = list.item(i);
if (entry.getNodeType() != Node.ELEMENT_NODE) {
continue;
}
faultName = new QName(entry.getNamespaceURI(),
entry.getLocalName());
Class<?> clazz = callback.getWebFault(faultName);
try {
if (clazz != null) {
Class<?> faultInfo = clazz.getMethod("getFaultInfo").getReturnType();
Object obj = JAXBEncoderDecoder.unmarshall(callback.getJAXBContext(),
callback.getSchema(),
entry,
faultName,
faultInfo);
Constructor<?> ctor = clazz.getConstructor(String.class,
obj.getClass());
return ctor.newInstance(fault.getFaultString(), obj);
}
} catch (Exception ex) {
throw new WebServiceException("error in unmarshal of SOAPFault", ex);
}
}