I had a similar problem some time ago, maybe my solution could help you.
In my case, I had a service returned a data type parent, but really what
were encapsulated sub-types in the inheritance and throws an error when
deserializing, I resolved to as follows:
I recommend that instead of returning anyType, create a class to inherit
father and put each type of data you want to return to inherit from that
class
public synchronized Object[] invoke(String methodName, Object[] args,
Class retType) throws AxisFault {
Notification notif = fireNotifyEvent(NotifLevel.CALL, "Calling
" + methodName + " Operation.", null);
Object[] response = null;
try {
OMElement payload = createPayload(methodName, args);
OMElement omResponse = servClient.sendReceive(payload);
response = BeanUtil.deserialize(omResponse,
getClassArrayOfTypeFromOMElement(retType, omResponse), new
DefaultObjectSupplier());
fireNotifyEvent(NotifLevel.RESPONSE, "Calling " +
methodName + " Operation.", notif);
} catch (AxisFault ex) {
Logger.getLogger(WSClient.class.getName()).log(Level.SEVERE, null, ex);
fireNotifyEvent(NotifLevel.ERROR, ex.getMessage(), notif);
throw ex;
}
return response;
}
private Object[] getClassArrayOfTypeFromOMElement(Class type, OMElement
oMElement) {
List<Class> list = new ArrayList<Class>();
Iterator iterator = oMElement.getChildElements();
while (iterator.hasNext()) {
Object next = iterator.next();
if (next instanceof OMElement) {
OMElement element = (OMElement) next;
Iterator attrs = element.getAllAttributes();
Class classType = null;
while (attrs.hasNext()) {
OMAttribute attr = (OMAttribute) attrs.next();
if ("type".equals(attr.getLocalName())) {
String[] components =
attr.getAttributeValue().split(":");
String typeName = components[0];
oMElement.getFirstElement().getAttribute(new
QName("xmlns:" + typeName));
Iterator nsIt =
oMElement.getAllDeclaredNamespaces();
while (nsIt.hasNext()) {
OMNamespace ns = (OMNamespace) nsIt.next();
if (typeName.equals(ns.getPrefix())) {
try {
URL url = new
URL(ns.getNamespaceURI());
String host = url.getHost();
String[] splitedHostName =
host.split("\\.");
String typePackage = "";
for (String pack : splitedHostName) {
typePackage = pack + "." +
typePackage;
}
String className = typePackage +
components[1];
classType = Class.forName(className);
} catch (Exception ex) {
}
}
}
}
}
list.add(classType != null ? classType : type);
}
}
return list.toArray();
}
I hope this helps you
I speak spanish, my english is bad
Fin a la injusticia, LIBERTAD AHORA A NUESTROS CINCO COMPATRIOTAS QUE SE
ENCUENTRAN INJUSTAMENTE EN PRISIONES DE LOS EEUU!
http://www.antiterroristas.cu
http://justiciaparaloscinco.wordpress.com