public static List unWrapPart(Part p, Definition def) throws WSIFException {
ArrayList l = new ArrayList();
Parser.getAllSchemaTypes(def, l, null);
if (l == null || l.size()<1) {
throw new WSIFException("no schema elements found");
}
QName partQN = p.getElementName();
if (partQN == null) {
throw new WSIFException("part has no QName");
}
ElementType et = null;
for (int i=0; i<l.size() && et==null; i++ ){
Object o = l.get(i);
if ( o instanceof ElementType ) {
QName etQN = ((ElementType)o).getTypeName();
if ( partQN.equals(etQN) ){
et = (ElementType)o;
}
}
}
if (et == null) {
throw new WSIFException("no ElementType found for part: " + p);
}
List children = et.getChildren();
if (children == null || l.size()<1) {
throw new WSIFException("no ComplexType children on elementType: " + et);
}
ComplexType ct = (ComplexType) children.get(0);
SequenceElement[] se = ct.getSequenceElements();
if (se == null) {
throw new WSIFException("no sequence elements found on: " + ct);
}
ArrayList unWrappedParts = new ArrayList();
for (int i=0; i< se.length; i++) {
PartImpl np = new PartImpl();
QName type = se[i].getTypeName();
if (type==null) {
throw new WSIFException("sequence element has no type name: " + se[i]);
}
np.setName(type.getLocalPart());
np.setElementName(se[i].getElementType());
unWrappedParts.add(np);
}