operationInfo.returnJavaType = wsdlReturnValueMapping.getMethodReturnValue();
}
private JaxRpcFaultInfo mapFaults(final Fault fault) throws OpenEJBException {
final Message message = fault.getMessage();
final ExceptionMapping exceptionMapping = mapping.getExceptionMappingMap().get(message.getQName());
if (exceptionMapping == null) {
throw new OpenEJBException("No exception mapping for fault " + fault.getName() + " and fault message " + message.getQName() + " for operation " + operationName);
}
// 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)
final Part part;
if (exceptionMapping.getWsdlMessagePartName() != null) {
// According to schema documentation, this will only be set when several headerfaults use the same message.
final String headerFaultMessagePartName = exceptionMapping.getWsdlMessagePartName();
part = message.getPart(headerFaultMessagePartName);
} else {
part = (Part) message.getOrderedParts(null).iterator().next();
}
// Determine the fault qname and xml schema type
final QName faultQName;
final XmlTypeInfo faultTypeInfo;
if (part.getElementName() != null) {
final XmlElementInfo elementInfo = schemaInfo.elements.get(part.getElementName());
if (elementInfo == null) {
throw new OpenEJBException("Can not find element: " + part.getElementName() + ", known elements: " + schemaInfo.elements.keySet());
}
faultTypeInfo = schemaInfo.types.get(elementInfo.xmlType);
if (faultTypeInfo == null) {
throw new OpenEJBException("Can not find type " + elementInfo.xmlType + " for element " + elementInfo.qname + ", known types: " + schemaInfo.types.keySet());
}
faultQName = part.getElementName();
} else if (part.getTypeName() != null) {
faultTypeInfo = schemaInfo.types.get(part.getTypeName());
if (faultTypeInfo == null) {
throw new OpenEJBException("Can not find type: " + part.getTypeName() + ", known elements: " + schemaInfo.types.keySet());
}
faultQName = new QName("", fault.getName());
} else {
throw new OpenEJBException("Neither type nor element name supplied for part: " + part);
}
//
// Build the fault info
//
final JaxRpcFaultInfo faultInfo = new JaxRpcFaultInfo();
faultInfo.qname = faultQName;
faultInfo.xmlType = faultTypeInfo.qname;
faultInfo.javaType = exceptionMapping.getExceptionType();
faultInfo.complex = faultTypeInfo.simpleBaseType == null;
//
// Map exception class constructor args
//
if (exceptionMapping.getConstructorParameterOrder() != null) {
if (faultTypeInfo.simpleBaseType != null) {
throw new OpenEJBException("ConstructorParameterOrder can only be set for complex types, not " + faultTypeInfo.qname);
}
final Map<String, XmlElementInfo> elements = new HashMap<String, XmlElementInfo>();
for (final XmlElementInfo element : faultTypeInfo.elements.values()) {
elements.put(element.qname.getLocalPart(), element);
}
final ConstructorParameterOrder constructorParameterOrder = exceptionMapping.getConstructorParameterOrder();
for (int i = 0; i < constructorParameterOrder.getElementName().size(); i++) {
final String paramName = constructorParameterOrder.getElementName().get(i);
// get the parameter element
final XmlElementInfo paramElementInfo = elements.get(paramName);