private FaultDesc mapException(String faultName, Fault fault) throws DeploymentException {
Message message = fault.getMessage();
QName messageQName = message.getQName();
ExceptionMappingType exceptionMapping = (ExceptionMappingType) exceptionMap.get(messageQName);
if (exceptionMapping == null) {
throw new DeploymentException("No exception mapping for fault " + faultName + " and fault message " + messageQName + " for operation " + operationName);
}
String className = exceptionMapping.getExceptionType().getStringValue().trim();
//TODO investigate whether there are other cases in which the namespace of faultQName can be determined.
//this is weird, but I can't figure out what it should be.
//if part has an element rather than a type, it should be part.getElementName() (see below)
QName faultQName = new QName("", faultName);
Part part;
if (exceptionMapping.isSetWsdlMessagePartName()) {
//According to schema documentation, this will only be set when several headerfaults use the same message.
String headerFaultMessagePartName = exceptionMapping.getWsdlMessagePartName().getStringValue();
part = message.getPart(headerFaultMessagePartName);
} else {
part = (Part) message.getOrderedParts(null).iterator().next();
}
QName faultTypeQName;// = part.getElementName() == null ? part.getTypeName() : part.getElementName();
if (part.getElementName() == null) {
faultTypeQName = part.getTypeName();
if (faultTypeQName == null) {
throw new DeploymentException("Neither type nor element name supplied for part: " + part);
}
} else {
faultQName = part.getElementName();
faultTypeQName = (QName) schemaInfoBuilder.getElementToTypeMap().get(part.getElementName());
if (faultTypeQName == null) {
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;