throw new DeploymentException("Can not find type for: element: " + part.getElementName() + ", known elements: " + schemaInfoBuilder.getElementToTypeMap());
}
}
SchemaType complexType = (SchemaType) schemaInfoBuilder.getComplexTypesInWsdl().get(faultTypeQName);
boolean isComplex = complexType != null;
FaultDesc faultDesc = new FaultDesc(faultQName, className, faultTypeQName, isComplex);
//constructor parameters
if (exceptionMapping.isSetConstructorParameterOrder()) {
if (!isComplex) {
throw new DeploymentException("ConstructorParameterOrder can only be set for complex types, not " + faultTypeQName);
}
Map elementMap = new HashMap();
SchemaProperty[] properties = complexType.getProperties();
for (int i = 0; i < properties.length; i++) {
SchemaProperty property = properties[i];
QName elementName = property.getName();
SchemaType elementType = property.getType();
elementMap.put(elementName.getLocalPart(), elementType);
}
ArrayList parameterTypes = new ArrayList();
ConstructorParameterOrderType constructorParameterOrder = exceptionMapping.getConstructorParameterOrder();
for (int i = 0; i < constructorParameterOrder.getElementNameArray().length; i++) {
String elementName = constructorParameterOrder.getElementNameArray(i).getStringValue().trim();
SchemaType elementType = (SchemaType) elementMap.get(elementName);
Class javaElementType;
QName elementTypeQName = elementType.getName();
if (elementTypeQName != null) {
if (schemaInfoBuilder.getComplexTypesInWsdl().containsKey(elementType)) {
String javaClassName = (String) publicTypes.get(elementTypeQName);
if (javaClassName == null) {
throw new DeploymentException("No class mapped for element type: " + elementType);
}
javaElementType = getJavaClass(javaClassName);
} else {
javaElementType = (Class) qnameToClassMap.get(elementTypeQName);
if (javaElementType == null) {
throw new DeploymentException("Unknown type: " + elementType + " of name: " + elementName + " and QName: " + elementTypeQName);
}
}
} else {
//anonymous type
//anonymous type qname is constructed using rules 1.b and 2.b
String anonymousQName = complexType.getName().getNamespaceURI() + ":>" + complexType.getName().getLocalPart() + ">" + elementName;
String javaClassName = (String) anonymousTypes.get(anonymousQName);
if (javaClassName == null) {
if (elementType.isSimpleType()) {
//maybe it's a restriction of a built in simple type
SchemaType baseType = elementType.getBaseType();
QName simpleTypeQName = baseType.getName();
javaElementType = (Class) qnameToClassMap.get(simpleTypeQName);
if (javaElementType == null) {
throw new DeploymentException("Unknown simple type: " + elementType + " of name: " + elementName + " and QName: " + simpleTypeQName);
}
} else {
throw new DeploymentException("No class mapped for anonymous type: " + anonymousQName);
}
} else {
javaElementType = getJavaClass(javaClassName);
}
}
//todo faultTypeQName is speculative
//todo outheader might be true!
ParameterDesc parameterDesc = new ParameterDesc(faultTypeQName, ParameterDesc.OUT, elementTypeQName, javaElementType, false, false);
parameterTypes.add(parameterDesc);
}
faultDesc.setParameters(parameterTypes);
}
return faultDesc;
}